以下程序 #include<stdio.h> #include<string.h> main() { char*p1="abc",*p2="ABC",str[50]="xy

题目
以下程序 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

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

第1题:

下面程序的输出结果是()。includeincludemain(){char p1[]="WHO",p2[]="who

下面程序的输出结果是( )。 #include<stdio.h> #include<string.h> main() {char p1[]="WHO",p2[]="who",str[50]="xyz"; strcpy(str+1,strcat(p1,p2)); printf("%s",str);}

A.xyzWHOwho

B.zWHOwho

C.zWHOwho

D.xWHOwho


正确答案:D

第2题:

以下C程序段的输出结果是(30)。 include void abc(char *str){ int a, b;

以下C程序段的输出结果是(30)。 #include <stdio. h> void abc(char *str){ int a, b; for(a=b=0;str[a]!='\O';a++)if(str[a]!='c') str[b++]=str[a]; str[b]='\O'; } void main(){ char str[]="abcdef"; abc(str); printf("str[]=%s",str); }

A.str[]=a

B.str[]=ab

C.str[]=abdef

D.str[]=abcdef


正确答案:C
解析:本试题核心在于子函数的for循环。For循环将整个字符串中的字符处理一遍,每次处理时,函数的基本工作是将除字母c之外的字符重新赋值,然后a++,b++,继续处理下一个字符。对于字母c不赋值,且只有a++而b不变。可见for循环的目的只是将字母c剔除。

第3题:

下面程序的输出结果是includeincludemain(){char *pl="abc",*p2="ABC",str

下面程序的输出结果是 #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.xyabcABC

D.yzabcABC


正确答案:C
解析: 本题考查的重点是拷贝字符串——使用strcpy()函数,该函数的调用方式是:strcpy(字符数组,字符串),其中”字符串”可以是字符串常量,也可以是字符数组。函数的功能是:将“字符串”完整地复制到“字符数组”中,字符数组中原有的内容被覆盖。
使用该函数时注意:①字符数组必须定义得足够大,以便容纳复制过来的字符串。复制时,连同结束标志'\0'一起复制;②不能用赋值运算符“:”将一个字符串直接赋值给一个字符数组,只能用strcpy()函数处理。
另外,本题还考查连接字符串的strcat()函数,其调用方

第4题:

以下程序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”。

第5题:

下列程序段的运行结果是()。 include void main() {char str[]="ABC",*p=str; printf("

下列程序段的运行结果是( )。

#include<stdio.h>

void main()

{ char str[]="ABC",*p=str;

printf("%d\n",*(p+3) );

}

A.67

B.0

C.字符'C'的地址

D.字符'C'


正确答案:B
解析:先定义了一个指向字符型数组str的指针p,指针p指向数组str的首地址,p+3将指针指向str[3],又因为字符型数组在存放字符串时会自动在末尾加上'\0',所以*(p+3)=0。

第6题:

下面程序的输出结果为______。includemain(){charP[17]="abc"="ABC".STR[50]="xyz";st

下面程序的输出结果为______。 #include<string.h> main() { charP[17]="abc"="ABC".STR[50]="xyz"; strcpy(str,strcat(p1,p2)); printf(%s,str); }

A.xyzabcABC

B.abcABC

C.xyzabc

D.xyzABC


正确答案:B
解析:strcpy(strl,s1):作用是将字符串s1拷贝到字符数组strl中去。strcat(字符数组1,字符数组2):把字符串2接到字符串1的后面,结果放在字符数组1中,函数调用后返回字符数组1的地址。本题定义了三个字符数组pl,p2,str,strcat(pl,p2)函数的作用是将字符串数组p2接到字符串p1的后面,结果放在字符数组p1中,再通过strcpy()函数将该字符串拷贝到str数组中,原str数组中的字符串xyz被覆盖,因此打印输出字符串str即可得到abcABC。

第7题:

当执行下面的程序时,如果输入ABC,则输出结果是 ( ) include include

当执行下面的程序时,如果输入ABC,则输出结果是 ( ) # include<stdio.h> # include<string.h> main( ) { char ss [10] ="12345"; gets(ss);strcat(ss"6789");printf("%s\n",ss); }

A.ABC6789

B.ABC67

C.12345ABC6

D.ABC456789


正确答案:A

第8题:

下面程序的输出结果是

#include

#include

void main()

{

char p1[10],p2[10];

strepy(p1,”abc”):

strcpy(p2,”ABC”);

char str[50]=”xyz”;

strcpy(str+2,strcat(p1,p2));

cout <

}

A.xyzabcABC

B.zabcABC

C.xyabcABC

D.yzabcABC


正确答案:C

第9题:

以下程序的输出结果是 ______。includeincludevoidmain(){char *p1=",he

以下程序的输出结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char *p1=",hello",*p2="world!",str[50]:"Hii"; strcpy(str+2,p1); strcat(str,p2); cout<<str; }

A.Hii,hello world!

B.hello world!

C.ii,hello world!

D.Hi,hello world!


正确答案:D

第10题:

以下程序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”。

更多相关问题