char *p="abcdefgh";p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")))
人气:292 ℃ 时间:2020-05-27 07:03:04
解答
你这是错误代码.错在char *p="abcdefgh";这样定义的字符串是常字符串,不能进行写操作,所以strcpy(p,"ABCD")是非法语句,会出现运行时错误.这样改正:char a[]=
"abcdefgh",*p=a;p+=3;printf("%d\n",strlen(strcpy(p,"ABCD")));就可以了.结果应该是4,就是拷贝进去的ABCD的长度.没有试,你试试……
推荐
- 下面程序段的运行结果是( ).char *p="abcdefgh"; p+=3; printf("%d\n",strlen(strcpy(p,"ABCD")
- char *s1="12345",*s2="1234"; printf("%d\n",strlen(strcpy(s1,s2)));
- 已知:char a[20]= "abc",b[20]= "defghi";则执行下列语句后printf("%d",strlen(strcpy(a,b)));
- { char a[30]="nice to meet you!"; strcpy(a+strlen(a)/2,"you"); printf("%s\n",a);
- 设char*1=“12345”,s2=“1234”;执行语句printf(“%d\n”,strlen(strcpy(s1,s2)));后的输出结果是?
- 等腰梯形ABCD中,角B=60度,AD平行BC,角BAC等于90度,他的中位线长为12CM,求这个等腰梯形的周长
- 如果你只有一个5升水桶和一个3升水桶这两个容器,均无刻度,如何准确量出4升水?
- 海伦公式怎么推导
猜你喜欢