I had an inverview today, and was asked to write a function of two strings concatenation. But after I’ve finished, I’ve heard, that generally the code is ok, but I’ve done a little error there. Checked it at home, but everything is working. Whats the problem?
char * strconcat (char *S1, char *S2){
char *S3 = new char [strlen(S1) + strlen(S2) +1];
strcpy(S3, S1);
strcat(S3, S2);
return S3;
}
1 Answer