I*I 发帖数: 618 | 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? | h**********l 发帖数: 6342 | 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",
| I*I 发帖数: 618 | 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",
| I*******l 发帖数: 203 | 4 change the code to:
marysLamb = marysLamb + "Mary had a little lamb,\n" +.... | h**********l 发帖数: 6342 | 5 你试试看阿
【在 I*I 的大作中提到】 : 你是说改成空格就行吗? : 好像不行吧
| I*******l 发帖数: 203 | 6 Yes, just checked space also works. But why? | r********g 发帖数: 1351 | 7 行的吧
【在 I*I 的大作中提到】 : 你是说改成空格就行吗? : 好像不行吧
| h**********l 发帖数: 6342 | 8 now ,you learn something . :)
【在 I*******l 的大作中提到】 : Yes, just checked space also works. But why?
|
|