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?
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?