This item was added on: 2003/02/19
When writing output in C++, you can use either
'\n' to produce a newline, but each has a different effect.
std::endl sends a newline character
'\n' and flushes the output buffer.
'\n' sends the newline character, but does not flush the output buffer.
The distinction is very important if you're writing debugging messages that you really need to see immediately, you should always use std::endl rather than '\n' to force the flush to take place immediately.
The following is an example of how to use both versions, although you cannot see the flushing occuring in this example.
std::cout <<"Testing 1" <<std::endl;
std::cout <<"Testing 2\n";