Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char* prepare_repeated_message(char* message, int repeat){
- int len = strlen(message)*repeat+repeat;
- char *buffer = (char*)malloc(len+1);
- for(int i = 0; i<repeat; i++) {
- strcat(buffer,message);
- if(i<repeat-1) strcat(buffer, "\n");
- }
- buffer = BytesToString(buffer, 0, len+1, "UTF8");
- return buffer;
- }
- int main() {
- char* o = prepare_repeated_message("Hallo Osiris!", 3);
- printf("%s", o);
- free(o);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement