以下程序:#include<stdio.h>#include<string.h>main(){char str[]="abcd\n\123\xab";printf("%d"

题目
以下程序:includeincludemain(){char str[]="abcd\n\123\xab";printf("%d"

以下程序: #include<stdio.h> #include<string.h> main() {char str[]="abcd\n\123\xab"; printf("%d",(str)); } 运行后的输出结果是( )。

A.10

B.9

C.7

D.14

如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

将输入的字符串按逆序输出,例如输入abcd,则按dcba顺序输出出来,请完善程序。 #include <stdio.h> #include <string.h> int main() { char *str, s[20]; int n; str=s; scanf("%s",str); n=strlen(str); while(--n>=0) { str=&s[____]; printf("%c",*str); } return 0; }


不唯一;

第2题:

将输入的字符串按逆序输出,例如输入abcd,则按dcba顺序输出出来,请完善程序。 #include <stdio.h> #include <string.h> int main() { char *str, s[20]; int n; str=s; scanf("%s",str); n=strlen(str); while(--n>=0) { str=&s[ ________ ]; printf("%c",*str); } return 0; }


不唯一;

第3题:

以下程序的输出结果是【 】。includeincludechar*fun(char*t){ char *p=t;retur

以下程序的输出结果是【 】。

include <stdio.h>

include <string.h>

char *fun(char *t)

{ char *p=t;

return (p+strlen(t)/2);

}

main()

{ char *str="abcdefgh";

str=ftm(str);

puts(str);

}


正确答案:
efgh 解析:本题考查的知识点是:字符指针。题目中的fun()函数,通过strlen()库函数得到形参t所指字符串的长度。然后返回t所指字符串首地址值加上该长度值的一半。所以fun()函数的作用就是返回所给字符串的中间位置。故最后通过puts()输出的字符串为"efgh"。

第4题:

以下程序 include include main() { char*p1="abc",*p2="ABC",str[50]="xy

以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz"; strcpy(ar+2,strcat(p1,p2)); printf("%s\n",str); } 的输出是______。

A.xyzabcABC

B.zabeABC

C.yzabcABC

D.xyabcABC


正确答案:D
解析:strcat(p1,p2)将字符串abcABC防到了*p1所指向的存储单元中:strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

第5题:

以下程序 includeincludemain(){char*pl="abc",*p2="ABC",str[50]="xyz";

以下程序 #include<stdio.h> #include<string.h> main() { char*pl="abc",*p2="ABC",str[50]="xyz"; strcpy(str+2,strcat(p1,p2)); printf("%s\n",str); } 的输出是________。

A.xyzabcABC

B.zabcABC

C.yzabcABC

D.xyabcABC


正确答案:D
解析:strcat(p1,p2)将字符串abcABC放到了*p1所指向的存储单元中;strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

第6题:

以下程序includeincludemain(){ char*p1="abc",*p2="ABC",str[50]="xyz";s

以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz"; strcpy(str+2,strcat(p1,p2)); printf("%ss\n",str); } 的输出是______。

A.xyzabcABC

B.zabcABC

C.yzbcABC

D.xyabcABC


正确答案:D
解析:strcat(p1,p2)将字符串abcABC放到了*p1所指向的存储单元中;strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

第7题:

以下程序includeincludemain(){ char*p1="abc",*p2=-"ABC", str, [50]="xy

以下程序#include<stdio.h>#include<string.h>main(){ char*p1="abc",*p2=-"ABC", str, [50]="xyz"; strcpy(str+2,strcat(p1,p2)); printf("%s\n", str);}

A.xyzabcABC

B.zabcABC

C.yzabcABC

D.xyabcABC


正确答案:D
解析:strcat(p1,p2)将字符串abcABC放到了*p1所指向的存储单元中;strcpy在本题将abcABC复制到sir+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

第8题:

以下程序includeincludemain(){ char*pl="abc",*p2="ABC",str[50]="xyz";s

以下程序 #include<stdio.h> #include<string.h> main() { char*pl="abc",*p2="ABC",str[50]="xyz"; strcpy(str+2.strcat(p1,p2)); printf("%s\n,str); } 的输出是______。

A.xyzabcABC

B.zabcABC

C.yzabcABC

D.xyabcABC


正确答案:D
解析: strcat(p1,P2)将字符串abcABC放到了*pl所指向的存储单元中;strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。

第9题:

以下程序includeincludemain(){char*p1="abc",*p2="ABC",str[50]="xyz", s

以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xyz", strcpy(str+2,strcat(p1,p2)); printf("%s\n",str); } 的输出是______。

A.xyzabcABC

B.zabcABC

C.yzabcABC

D.xyabcABC


正确答案:D
解析:strcat(p1,p2)将字符串abcABC放到了*p1所指向的存储单元中;strcpy在本题将abcABC复制到str+2所指向的存储单元中,即覆盖原str数组中的字符z及其后的所有字符,故str的值为“xyabcABC”。