Does new line character also flush the buffer?

Converting comments into an answer. It depends on where cout is going. If it goes to a terminal (‘interactive device’), then it can’t be fully buffered — it is usually line buffered, meaning that characters appear after a newline is printed, or could in theory be unbuffered. If it is going to a pipe or … Read more

What is the C++ iostream endl fiasco?

(I assume) He just means that many, especially new, C++ programmers use std::endl blindly instead of ‘\n’ for newline, flushing unnecessarily frequently and potentially making the performance of their program abysmal. I.e., most people are taught that std::endl is the canonical way to insert a newline into a stream even though it is very rarely … Read more