C is always pretty awkward with strings, but it's usually okay to just allocate a char array of size 256 for your string and be on with it.
However, what if you want the function to return a string and you don't know the size, since you will be concatenating strings together dozens or hundreds of times? Obviously something like this won't work:
char * my_function(int n, char *string){
if (n < 20) {
return string;
}
else {
char *new_string = "abcdefghijklmnop";
strcat(string, new_string);
return my_function(n--, string);
}
}
So how is this handled in c?