Many people say that in C++ endl
is much slower than \n
when printing a string. They explain that endl
flushes the buffer and \n
doesn't. In the book C Primer Plus it's said that
"Sending the output from the buffer to the screen or file is called flushing the buffer."
and that
"The standard C rules for when output is sent from the buffer to the screen are clear: It is sent when the buffer gets full, when a newline character is encountered, or when there is impending input."
So isn't technically printing an newline character flushing the buffer and still why is endl
slower ?