下面程序的输出结果是()。#include<iostream>#include<string>using namespace std;void main(){c

题目
下面程序的输出结果是()。includeincludeusing namespace std;void main(){c

下面程序的输出结果是( )。 #include<iostream> #include<string> using namespace std; void main(){ charp1[10],p2[10]; strcpy(p1,"abc"); strcpy(p2,"ABC"); charstr[50]="xyz"; strcpy(str+2,strcat(p1,p2)); cout<<str; }

A.xyabcABC

B.yzabcABC

C.xyzabcABC

D.zabcABC

参考答案和解析
正确答案:A
解析:本题考查字符串操作函数和指针的使用。strcat(p1,p2)将字符串p1和p2连接,接着调用strcpy函数,从数组str的第3个位置开始复制连接后的字符串,因此本题答案为xyabcABC。
如果没有搜索结果或未解决您的问题,请直接 联系老师 获取答案。
相似问题和答案

第1题:

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

A.ABC

B.ABC9

C.123456ABC

D.ABC456789


B

第2题:

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

A.ABC

B.ABC9

C.123456ABC

D.ABC456789


Astrcat函数,gets函数;首先将输入的字符串赋给ss,然后将字符串“6789”连接到ss得后

第3题:

当执行下面程序且输入a boy时,输出的结果是______。includeincludemain(){c

当执行下面程序且输入a boy时,输出的结果是______。 #include<stdio.h> #include<string.h> main() { char ss[81]="A BOY",hh[81],*pt; scanf("%s",hh); pt=strcat(ss,hh); puts(pt); printf("%s\n",hh); }

A.A BOY a a

B.A BOY a boy a boy

C.A BOY a boy a

D.A BOY a boy a boy


正确答案:A
解析:对于函数strcat(ss,hh),把字符串hh(若遇空格,舍去后面的部分,并重新赋给hh)连至字符串ss的后面。

第4题:

下列程序的输出结果是( )。 include include"string.h" void main() {char a[]="He

下列程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; }

A.Hello

B.Test

C.Hello Test

D.Hello Test HelloTest


正确答案:B
解析:程序中首先定义字符数a和b,其值分别为“Hello Test”和“Test”。然后利用strcpy复制函数,将b的值复制给a,所以输出a的结果为Test。

第5题:

下列程序的输出结果是______。includeinclude using namespace std;void

下列程序的输出结果是______。

include <iostream.h>

include <cstring.h>

using namespace std;

void fun(const char*s,char &C) {c=s[strlen (s)/2];}

int main {)

{

char str [] ="ABCDE";

char ch=str[1];

fun(str,sh);

cout<<Ch;

return 0;

}


正确答案:C
C 解析:本题考核数组的定义、使用以及函数的调用。fun函数的作用是将字符串str中间的字符赋值给地址传入的变量ch。所以ch的值将被修改为‘C’。

第6题:

下面程序的输出结果是()。includeinclude"string.h"void main(){char a[]="Hello T

下面程序的输出结果是( )。 #include<iostream.h> #include"string.h" void main() {char a[]="Hello Test",b[]="Test"; strcpy(a,b); cout<<a<<end1; } A) B)

C) D)

A.Hello

B.Test

C.Hello Test

D.Hello Test HelloTest


正确答案:B

第7题:

下列程序的输出结果是【】。 include include void main(){ char b[30]; str

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

include<iostream.h>

include<string.h>

void main(){

char b[30];

strcpy(&b[0],"XY");

strcpy(&b[1],"YZW");

strcpy(&b[2],"ZXY");

cout<<b<<end1;

}


正确答案:XYZXY
XYZXY

第8题:

当执行下面的程序时,如果输入ABC,输出结果是 ______。includeincludevoi

当执行下面的程序时,如果输入ABC,输出结果是 ______。 #include<iostream.h> #include<string.h> void main(){ char ss[10]=“XYZWV”; cin>>ss; strcat(ss,”DEFG”); cout<<ss; }

A.ABCDEFG

B.ABCEF

C.XYZVO/ABCX

D.ABCXYZWVD


正确答案:A

第9题:

以下程序的输出结果是【】。 include include void main 0 { char s[50]; st

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

include<iostream.h>

include <string.h>

void main 0 {

char s[50];

strcpy(&s[O], "No" );

strcpy(&s[1], "123" );

strcpy (&s[2], "23456" );

cout<<s;

}


正确答案:N123456
N123456