I have been told that quotation marks are used to enclose string constants. In the code given below I used different methods to insert a blank line space between the text lines.
In the case of using '\n' you either have a choice to use it within the string, such as "Hello, how are you?\n"; , or to use it separately, such as "Hello, how are you?" << "\n";.
In both cases I don't get how the compiler or C++ knows that I'm asking it to go to next line because in the first I'm using \n with in a string constant, and in the second it is simply with in quotation marks, and anything within the quotes is tread as text.
This reminds me of another question. They say the distinction between endl and \n has something to do with the input buffer. What is it in simple words? Is there also a output butter?
Thanks for all your help, and especially your time.
Best regards
Jackson
#include <iostream>
using namespace std;
int main()
{
cout << "Yes, I this is a crazy act. Utter madness. I suggest you start\
thinking rationally" << endl;
cout << endl;
cout << "Yes, I this is a crazy act. Utter madness. I suggest you start"
<< " thinking rationally" << endl;
cout << "\n";
cout << "Yes, I this is a crazy act. Utter madness. I suggest you start "
"thinking rationally" << endl;
cout << " " << endl;
system("pause");
}


Sign In
Create Account


Back to top









