1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-09-19 14:16:55 +02:00
CodeWars/8kyu/string_repeat/solution.c
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

13 lines
285 B
C

#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;
}