strcat を自分で実装しようとしたところ、Wikiでこのような strcat の実装を見つけたのですが、使用するとセグメンテーション違反が発生します。
以下のコードの何が問題になっていますか?
char *
strcat(char *dest, const char *src)
{
size_t i,j;
for (i = 0; dest[i] != '\0'; i++)
;
for (j = 0; src[j] != '\0'; j++)
dest[i+j] = src[j];
dest[i+j] = '\0';
return dest;
}