char p[]="glorious",q[]="leader",t[9]; strcpy(t,p); strcpy(p,q); strcpy(q,t); printf("change after:char p[]="glorious",q[]="leader",t[9];\x05strcpy(t,p); strcpy(p,q); strcpy(q,t);printf("change after1:\n");\x05puts(p); puts(q);为什么结果是 chan
来源:学生作业帮助网 编辑:作业帮 时间:2024/08/01 08:14:54
![char p[]=](/uploads/image/z/13889888-8-8.jpg?t=char+p%5B%5D%3D%22glorious%22%2Cq%5B%5D%3D%22leader%22%2Ct%5B9%5D%3B+strcpy%28t%2Cp%29%3B+strcpy%28p%2Cq%29%3B+strcpy%28q%2Ct%29%3B+printf%28%22change+after%3Achar+p%5B%5D%3D%22glorious%22%2Cq%5B%5D%3D%22leader%22%2Ct%5B9%5D%3B%5Cx05strcpy%28t%2Cp%29%3B+strcpy%28p%2Cq%29%3B+strcpy%28q%2Ct%29%3Bprintf%28%22change+after1%3A%5Cn%22%29%3B%5Cx05puts%28p%29%3B+puts%28q%29%3B%E4%B8%BA%E4%BB%80%E4%B9%88%E7%BB%93%E6%9E%9C%E6%98%AF+chan)
char p[]="glorious",q[]="leader",t[9]; strcpy(t,p); strcpy(p,q); strcpy(q,t); printf("change after:char p[]="glorious",q[]="leader",t[9];\x05strcpy(t,p); strcpy(p,q); strcpy(q,t);printf("change after1:\n");\x05puts(p); puts(q);为什么结果是 chan
char p[]="glorious",q[]="leader",t[9]; strcpy(t,p); strcpy(p,q); strcpy(q,t); printf("change after:
char p[]="glorious",q[]="leader",t[9];
\x05strcpy(t,p); strcpy(p,q); strcpy(q,t);
printf("change after1:\n");
\x05puts(p); puts(q);
为什么结果是 change after1:
\x05glorious
而不是 change after1:
leader
\x05glorious
char p[]="glorious",q[]="leader",t[9]; strcpy(t,p); strcpy(p,q); strcpy(q,t); printf("change after:char p[]="glorious",q[]="leader",t[9];\x05strcpy(t,p); strcpy(p,q); strcpy(q,t);printf("change after1:\n");\x05puts(p); puts(q);为什么结果是 chan
测试结果:
change after1:
leader
glorious
请按任意键继续...
正确的代码
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
main()
{
char p[]="glorious",q[]="leader",t[9];
\x05strcpy(t,p);
strcpy(p,q);
strcpy(q,t);
printf("change after1:\n");
\x05puts(p);
puts(q);
system("pause");
}