appending a string onto end of another string
I have been reviewing this stuff on strings and I am confused.
Function needs to append contents of string s2 to the end of string 1 and return a pointer to resulting string.
Would the following work using the function declaration as shown???
Code:
char * catstr(char * s1, const char * s2)
{
char *pc;
pc = s1;
while (*pc != '\0')
pc++;
while (*s2 != '\0')
{
*pc = *s1;
pc++;
s1++;
}
*pc = '\0';
return s1;
}
I am still confused with functions with pointers as function types and as function parameters (arguments).
This is for review for my final. It's been a while since working with simplified code like this. I feel I am either missing something or making this more complicated than it should be.
Also, if not using strcat or strcpy commands, is there other ways to append strings to other strings???