char *str1 = malloc(256*sizeof(char));
char *str2 = "stack"
for (i=0;i<15;i++){
sprintf(str1,"%s%s",str1,str2);
}
printf("%s\n",str1);
I’m trying to concat str2 to str1 at each loop count. But this code segment works but vulnerable.
Whats the best way to concat them?
If you want to use sprintf; something like this: