Possible Duplicate:
Any better suggestions for this c functions copyString,concatString
I'm trying to write strcat using pointers, I can't change the main().
void str_cat(char **s1,char *s2) {
while(**s1)
*(s1++); /* go to the end of string1*/
/* copy string 2 at the end of string 1*/
while(*s2)
*(s1++) = (s2++);
puts(*s1);
}
I call the function from the main as follow:
char *str = NULL;
str_cat(&str, " World!");
The problem is when I try to get to the end of s1, but it's not incrementing correctly.
Thanks!