1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 16:43:46 +01:00
CodeWars/8kyu/string_repeat/solution.c

14 lines
285 B
C
Raw Normal View History

#include <string.h>
char *repeat_str(size_t count, const char *src) {
char* result = (char *) malloc(strlen(src) * count);
size_t upper = count * strlen(src);
size_t len = strlen(src);
for (size_t i = 0; i < upper; i += len)
strcpy(&result[i], src);
return result;
}