Advertisement
madegoff

sssssssssssssssssssssssss

Nov 9th, 2023
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.54 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. char* prepare_repeated_message(char* message, int repeat){
  6.  
  7.     int len = strlen(message)*repeat+repeat;
  8.     char *buffer = (char*)malloc(len+1);
  9.     for(int i = 0; i<repeat; i++) {
  10.             strcat(buffer,message);
  11.             if(i<repeat-1) strcat(buffer, "\n");
  12.     }
  13.     buffer = BytesToString(buffer, 0, len+1, "UTF8");
  14.     return buffer;
  15. }
  16.  
  17. int main() {
  18.     char* o = prepare_repeated_message("Hallo Osiris!", 3);
  19.     printf("%s", o);
  20.     free(o);
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement