以下三条输出语句分别输出什么?char str1[] = "abc";char str2[] = "abc";const char str3[] = "abc";const char str4[] = "abc";const char* str5 = "abc";const char* str6 = "abc";cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?cout << boolalpha << ( str3==str4 ) << endl;

题目

以下三条输出语句分别输出什么?

char str1[] = "abc";

char str2[] = "abc";

const char str3[] = "abc";

const char str4[] = "abc";

const char* str5 = "abc";

const char* str6 = "abc";

cout << boolalpha << ( str1==str2 ) << endl; // 输出什么?

cout << boolalpha << ( str3==str4 ) << endl; // 输出什么?

cout << boolalpha << ( str5==str6 ) << endl; // 输出什么?


相似考题
更多“以下三条输出语句分别输出什么?char str1[] = "abc";char str2[] = "abc";const char str3[] = ”相关问题
  • 第1题:

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

  • 第2题:

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

  • 第3题:

    18、以下程序的运行结果是: #include <stdio.h> char *fun(char *px,char *py); void main() { printf("%s%s\n",fun("abc","abcd"),fun("1234","123")); } char *fun(char *px,char *py) { return (*px > *py? px : py); }

    A.abcd1234

    B.abc1234

    C.abcd123

    D.abc123


    20 0 20 0

  • 第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("%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”。

  • 第5题:

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