Define a C-string function
void append(const char * v, const char * w, char * buffer)
that appends the characters of C-string w to the characters of C-string v and stores the result in buffer. (Don't forget the terminating null character .)
You can assume that the function is called with a buffer whose size is at least the sum of the sizes of v and w.
Use pointer notation. No square brackets allowed.
Here is my solution:
void append(const char *v, const char *w, char *buffer)
{
const char *p = v;
while(*p != '\0')
{
p++;
}
while(*w != '\0')
{
*p++ += *w++;
}
*buffer = *p;
p = '\0';
}
Right now, all I am getting is the error message: assignment of read-only location. This is occurring in this line: *p++ += *w++. Is there anything that I need to do to fix this error and get the correct solution?