void mystrcat(char* to, const char* from) {
while (*to) to++;
while (*from) *to++ = *from++;
*to = '\0';
}
int main() {
char addthis[]= "rest of the sentence";
char start_of[] = "going to add ";
mystrcat(start_of, addthis);
cout << "after strcat(): " << start_of<< endl;
}
even if i replace the function mystrcat to follows, behaviour is same.
char* mystrcat(char* to, const char* from) {
while (*to) to++;
while (*from) *to++ = *from++;
*to = '\0';
return to;
}
strange for me, when i call mystrcat i dont assign to a char* still no compiler's complain. what am i missing here? follow up can u optimize my code with void return type if anyway