Are there more output buffers? If so, does endl only flush the output buffer which is associated with cout? If there is only one buffer, then what makes the two objects cerr and clog distinct?
Are there more output buffers? If so, does endl only flush the output buffer
Share
endlflushes the output buffer of whichever stream you stream it to. For example:The only difference between
cerrandclogis thatclogis buffered by default, whilecerris not. You can turn buffering on or off for any stream using thestd::unitbufandstd::nounitbufmanipulators. For example:Note that “unitbuf” means “make the buffer size 1”, i.e. turn off buffering.