I don't have a specific context in which I'm asking the question, but while I was reading a beginner book on C++ I noticed the use of both an endl stream manipulator and a newline escape character when dealing with a stream object.
The exmaple is as follows:
cout << "Hello World" << endl; cout << "Hello World\n";
My questions are:
- Is it more appropriate to use the stream manipulator (endl) in a certain situation and an escape character in a different one?
- Are there drawbacks efficiency wise to using one of the two?
- Are they completely interchangeable?
- I read that an escape sequence is stored in memory as a single character. Does that mean it is more appropriate to use endl if you're going for low memory consumption?
- Does the stream manipulator endl use up memory in any way, if so is it more than the escape sequence?
Thanks, StackExchange Apologies if I posted this in the wrong section, I thought it counted as data structures.