string concatenation, the hard way

Jan 27, 2013 at 9:22pm
Greetings people of cplusplus.com, I am working on a task wherein I am required to create my own strcat function, using the same function prototype as the c library function:
char * strcat ( char * destination, const char * source );

I have already been able to solve this problem using array subscripting, but for this task I am also required to solve the problem using pointer arithmetic.

I am not so sure how to go about doing this, and it is difficult to find any examples to learn from for this particular problem, since most people would naturally use the built-in function rather than make their own.

Any tips or suggestions for concatenating two strings using pointer arithmetic?
Jan 27, 2013 at 9:27pm
destination[i] is the same as *(destination+i). Voila! Pointer arithmetic.
Jan 28, 2013 at 5:28am
Thank you very much, this is exactly what I needed... not sure why it didn't look so simple untill now XD
Last edited on Jan 28, 2013 at 5:29am
Topic archived. No new replies allowed.