#C1050. 字符串选择题测试
字符串选择题测试
- 有如下定义,则
str[5]的值是( )
char str[] = "hello";
{{ select(1) }}
'o''\0''h'- 不确定
- 关于下面两个数组,说法正确的是( )
char a[] = "abc";
char b[] = {'a', 'b', 'c'};
{{ select(2) }}
- 两者末尾都自动有
'\0' a末尾有'\0',b末尾没有自动补'\0'b末尾会自动补'\0'- 两者末尾都没有
'\0'
- 执行下面代码,输出是( )
string s = "hello";
s[0] = 'H';
s += "!";
cout << s;
{{ select(3) }}
hello!HelloHello!- 编译错误
- 执行下面代码,输入
hello world后回车,输出是( )
string s;
cin >> s;
cout << s;
{{ select(4) }}
hello worldhelloworld- 空
- 执行下面代码,输入
hello world后回车,输出是( )
string s;
getline(cin, s);
cout << s;
{{ select(5) }}
hello worldhelloworld- 空
- 执行下面代码,输入
Tom后回车,输出是( )
char name[20];
cin >> name;
cout << name;
{{ select(6) }}
TomTom- 空
- 执行下面代码,输出是( )
string s1 = "abc", s2 = "abc";
cout << (s1 == s2);
{{ select(7) }}
01abc- 编译错误
- 下列哪个语句能把
"world"接到 string 变量s原有内容之后?( )
{{ select(8) }}
s = "world";s += "world";s[0] = "world";s + "world";
- 执行下面代码,输出是( )
char c[] = "abc\0def";
cout << c;
{{ select(9) }}
abcabcdefabc\0def- 编译错误
- 执行下面代码,输出是( )
string s = "abc";
s = s + "def";
cout << s;
{{ select(10) }}
abcdefabcdefabc def