C + + On the difference between the three cerr,clog,cout:
Cerr (no buffer standard error)----- without buffering , the content sent to it is immediately output
Clog (buffer standard error)-------- buffer, buffer full-time output cout-------------------------standard output three are Ostream class defined output stream object, cout is in the terminal display output, The cout stream opens up a buffer in memory to hold the data in the stream, and when a endl is inserted into the cout stream, all data in the stream is immediately output, regardless of whether the buffer is diffuse, and then a newline character is inserted. The Cerr stream object is a standard error stream, specified as associated with the monitor, and the cout function is similar, a bit different is that the cout is usually transmitted to the display output, but can be redirected to the output of the file, and the information in the Cerr stream can only be output on the monitor.
Clog flow is also the standard error stream, the role and Cerr, the difference is that Cerr does not go through the buffer, directly to the display output information, and clog information in the buffer, the buffer is full or encountered Endl output.
Reprint Address: http://blog.csdn.net/templxj/article/details/1496629
About buffers:
Endl is a special value, called a manipulator, that has the effect of outputting a line break when it is written to the output stream, and refreshes the buffer associated with the device. By flushing the buffer, the user can immediately see the output written to the stream. Programmers often insert output statements during debugging, and these statements should flush the output stream. Forgetting to flush the output stream may cause the output to stay in the buffer, and if the program crashes, it will cause the program to infer the crash location incorrectly.
So what is a flush buffer? Find the following information online:
When a file is opened in a buffered manner, a few bytes are written to the file, and the bytes are not actually written to the file immediately, but only when the buffer is full. If you want to save the disk before the buffer is full, you can do the flushing buffer action.
The following behavior causes Flushing action: 1) when the buffer is full, 2) when the output is Endl,cerr or CIN, 3) performs a flushing function; 4) closes the file.
Original address: http://blog.csdn.net/mvpsendoh/article/details/6025882
Spin: The difference between the three in C + + about Cerr,clog,cout