Hello,
So I guess I have a problem with understanding the whole string issue in C, since i've been working on this little piece of code for a while now, trying to achieve what I want.
Here is the code. How do I add two strings (head and body) into one string and return it to the caller?
The thing is that I dont know the size of the string that respose will contain (well, I know, but I try to do it differently), and so I can't declare it as a char array, and so I can't use strcat(). If I do declare it as char array, then I cant return it, because it is a local variable.Code:char* compose(int type){ char *response, *head, *body; switch (type){ case 1:{ head=f1(); body=f2(); break; }case 2:{ ... } ... } //Some code to do here - adding head and body into response return response; }
Anyone can give me a hand here?
Thanks in advance!