Cout is a row-level buffer, and it will be flushed once it encounters a newline character. However, the cout object will also be flushed once when it is destroyed. In your example, the cout object needs to be destroyed once before returning 0. In terms of cerr, I have forgotten what it said in APUE. After debugging, I found that there is no buffering...
Cout is a row-level buffer, and it will be flushed once it encounters a newline character. However, the cout object will also be flushed once when it is destroyed. In your example, the cout object needs to be destroyed once before returning 0.
In terms of cerr, I have forgotten what it said in APUE. After debugging, I found that there is no buffering...
You will experience it when you are multi-threaded. If the cache is not cleared, the logs of thread A may be printed on thread B