Created
October 8, 2018 00:53
-
-
Save louipc/be8d85357805c9322ce38786ee65aca6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Repeat given string | |
| */ | |
| #include <string.h> | |
| #include <stdio.h> | |
| #include <stdint.h> | |
| #include <stdlib.h> | |
| char *repeat_str(int count, const char *src) { | |
| char *dest = malloc((strlen(src)*count)+1); | |
| for (int i=0; i < count; i++) { | |
| strcat(dest, src); | |
| } | |
| return dest; | |
| } | |
| int main() { | |
| char input[2^13]; | |
| int x; | |
| printf("Repeat number: "); | |
| scanf("%d", &x); | |
| printf("Repeat string: "); | |
| scanf("%s", input); | |
| printf("%s\n", repeat_str(x, input)); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment