avatar
I*I
1
Consider the following C++ code:
01 #include
02 #include
03
04 int main(int argc, char *argv[])
05 {
06 std::string marysLamb;
07
08 marysLamb = "Mary had a little lamb,\n",
09 "little lamb, little lamb,\n",
10 "Mary had a little lamb,\n",
11 "whose fleece was white as snow.";
12
13 std::cout << marysLamb << std::endl;
14
15 return 0;
16 }
George wanted to write a program that prints out the first part of the “
Mary Had a Little Lamb” nursery rhyme. He wrote the above program, but it
does not work as expected.
Questions:
· What is the output of George’s program?
· And why is it not working as expected?
avatar
h*l
2
逗号阿
要是空格多好

【在 I*I 的大作中提到】
: Consider the following C++ code:
: 01 #include
: 02 #include
: 03
: 04 int main(int argc, char *argv[])
: 05 {
: 06 std::string marysLamb;
: 07
: 08 marysLamb = "Mary had a little lamb,\n",
: 09 "little lamb, little lamb,\n",

avatar
I*I
3
你是说改成空格就行吗?
好像不行吧

【在 I*I 的大作中提到】
: Consider the following C++ code:
: 01 #include
: 02 #include
: 03
: 04 int main(int argc, char *argv[])
: 05 {
: 06 std::string marysLamb;
: 07
: 08 marysLamb = "Mary had a little lamb,\n",
: 09 "little lamb, little lamb,\n",

avatar
I*l
4
change the code to:
marysLamb = marysLamb + "Mary had a little lamb,\n" +....
avatar
h*l
5
你试试看阿

【在 I*I 的大作中提到】
: 你是说改成空格就行吗?
: 好像不行吧

avatar
I*l
6
Yes, just checked space also works. But why?
avatar
r*g
7
行的吧

【在 I*I 的大作中提到】
: 你是说改成空格就行吗?
: 好像不行吧

avatar
h*l
8
now ,you learn something . :)

【在 I*******l 的大作中提到】
: Yes, just checked space also works. But why?
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。