we all know that C + + has pre-defined CIN (standard input stream) and cout (standard output stream). But today it popped out again. Two cerr (standard error stream (non-buffered)) and clog (standard error stream (buffered))
, the spirit of learning to improve the online search for relevant content, the following is from Baidu know what to get
PS: I don't know if it will infringe ...
First, an example is used to analyze the difference between cout and Cerr, compile the following code after the link is generated test.exe
1#include <iostream.h>2 3 intMain ()4 {5cout <<"Hello World---cout"<<Endl;6Cerr <<"Hello World---cerr"<<Endl;7 return 0;8}
that is, the output of cout can be redirected to a file, and Cerr must be output on the monitor .
re-analyze the difference between cerr and clog, both are standard error streams, the difference is that Cerr does not go through the buffer, directly to the display output information, The information in the clog is stored in the buffer when the buffer is full or when Endl is encountered.
, You say, where do you go to borrow memory and store your error messages?
so there's cerr. The goal is to get support for the output function in the emergency situations where you need it most.
several sentences "at the same time" appear on the screen (from the memory to the video, then refresh the screen).
pps: The above content is from the network and is not validated and is for learning reference only.
C + + cout Cerr and Clog differences