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

来源:学生作业帮助网 编辑:作业帮 时间:2024/10/18 20:43:32
char *p=
xJA_%a;W?oQ]ReX( )5VQdl"]e%ffǫ^ M |fw~ ǓYY]1AN$SqVV9 CE@zVB I|HᰔP#?$d^ZF[q~L?oi/? =j۟%"vϹw{״b 5qkHk&"3^:~uĽhgS6%|p[D,jQ:z5o$nu 4e6[Pv5/mD.DzAG=f`Dފ8R$e%&

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的长度.没有试,你试试……