I've read that '\n' is preferred over 'endl' for new line in c++ because 'endl' inserts new line and flushes the stream. Please tell me what is flushing the stream ?
I've read that '\n' is preferred over 'endl' for new line in c++ because 'endl' inserts new line and flushes the stream. Please tell me what is flushing the stream ?
Flushing a stream is more likely as Flushing the toilet, where in toilet Flushing the toilet is cleared and in Stream(I/O Stream) Flushing the "Buffer-memory" is cleared.(where here Buffer-memory is a memory which is used to store the data temporarily from/for the I/O streams).
So, everytime "Flushing the Stream(means using of "endl" )" might become the bottleneck of the program, means your program always slows down at this point.
for more on buffer visit : this