I tried to implement the strcat by myself, and I found the strcat implementation from Wiki like this......but when I use it, there is segmentation fault.
What's wrong with the code below?
char *
strcat(char *dest, const char *src)
{
size_t i,j;
for (i = 0; dest[i] != ''; i++)
;
for (j = 0; src[j] != ''; j++)
dest[i+j] = src[j];
dest[i+j] = '';
return dest;
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…