This item was added on: 2003/02/19
When writing output in C++, you can use either std::endl or '\n' to produce a newline, but each has a different affect.
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 following is an example of how to use both versions, although you cannot see the flushing occuring in this example.
#include <iostream>
int main(void)
{
std::cout <<"Testing 1" <<std::endl;
std::cout <<"Testing 2\n";
}
Credit: Eibro