69,382
社区成员
发帖
与我相关
我的任务
分享
#include<stdio.h>
#include<stdlib.h>
int main()
{
char *p = "daolang";
printf("%s\n", p);
strcpy(p, "123");
printf("%s\n", p);
system("pause");
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
char p[24] = "daolang";
printf("%s\n", p);
memset(p, 0, 24);
strcpy(p, "123");
printf("%s\n", p);
system("pause");
return 0;
}
这样输出就不会了~
daolang
段错误(吐核)
linux下gcc编译结果,由于p的地址未指定,所以strcpy调用会产生错误。