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/12/23 22:07:19
charp[]="glorious",q[]="leader",t[9];strcpy(t,p);strcpy(p,q);strcpy(q,t);printf("changeafter:charp[]

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");
}