0
Why is there no speech marks in between each word when you are putting each word on its own line.?
Original: cout << " Hello \n world! \n I \n love \n programming!"; Why doesn't this work as : cout << " Hello" \n "world!" \n "I" \n "love" \n "programming!";
2 Respostas
+ 4
Because \n is an ASCII symbol just like "A" or "@" and not a part of the programming language. Even if you want to cout nothing but a single line break \n, you need to put it in quotation marks:
cout << "\n";
cout << "line one\nline two"; will output:
line one
line two
endl is part of the programming language and not an ASCII symbol. That's why you have to interrupt the string every time you want to use endl and must not put it in quotation marks:
cout << "line one" << endl << "line two";
+ 1
Thank you so much