#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
char* solution(const char* my_string, int n) {
char* answer = (char*)malloc(sizeof(char)*strlen(my_string)*n+1);
int index = 0;
for(int i=0; i<strlen(my_string); i++){
for(int j=0; j<n; j++){
answer[index++]=my_string[i];
}
}
answer[strlen(my_string)*n]='\0';
return answer;
}
마지막에 '\0' 값 넣어쥬기...***
'전공부셔 > c' 카테고리의 다른 글
[프로그래머스] 특정 문자 제거하기 (0) | 2023.03.05 |
---|---|
calloc과 malloc 차이 (0) | 2023.03.05 |
정렬 (0) | 2023.02.26 |
[프로그래머스] 숨어있는 숫자의 덧셈 (1) (0) | 2023.02.26 |
배열 원소 개수 (0) | 2023.02.26 |