#include <stdio.h>
char *strcpy_r(char* s, char* t);
int main()
{
char *s = {"Bob"};
char *t = {"Billy"};
char *ptr;
ptr = strcpy_r(s, t);
printf("%s\n", ptr);
return 0;
}
char* strcpy_r(char* s, char* t)
{
if((*s = *t) != '\0')
strcpy_r(s + 1, t + 1);
return s;
}
私は練習のためにこれをやっているだけですが、コンパイルしたとき。メインからセグフォルトが発生しました。誰かがこのセグメント障害の原因を教えてもらえますか?