char *p="abcdefgh";p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")))

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/07 01:04:24
char *p=

char *p="abcdefgh";p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")))
char *p="abcdefgh";p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")))

char *p="abcdefgh";p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")))
你这是错误代码.错在char *p="abcdefgh";这样定义的字符串是常字符串,不能进行写操作,所以strcpy(p,"ABCD")是非法语句,会出现运行时错误.这样改正:char a[]=
"abcdefgh",*p=a;p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")));就可以了.结果应该是4,就是拷贝进去的ABCD的长度.没有试,你试试……