Daily bit(e) of C++ | std::endl
Daily bit(e) of C++ #479, Taking care with the usage of std::endl.
The std::endl represents a newline and a flush of the associated stream, which is why it should be avoided for performance reasons (flushing a stream is generally expensive), especially for standard I/O streams, which are, by default, also synchronized with C stdio.
When working with standard I/O streams, it is important to understand whether they are buffered (manual flush() is required to persist the content on a quick_exit/abort).
On top of that, some streams are tied together (flushing the other stream before every operation), std::cin with std::cout and std::cerr with std::cout.
Now I understand why you always put a \n in your examples, what would be the correct way to output a system dependant new line?