Output statements Whether it is the C-language printf () or cout << "" << Endl;
A bug appears in the Loop statement:
Here are two things that are not normal:
The following are normal:
Possible causes:
"\ n" indicates a string with the content as a carriage return character. The Std::endl is a stream operator, and the output is similar to the output "\ n", but may be slightly different.
Std::endl outputs a newline character and immediately flushes the buffer.
For example
Std::cout << Std::endl;
Equivalent
Std::cout << ' \ n ' << std::flush;, or
Std::cout << ' \ n '; Std::fflush (stdout);.
Because of the overloads of the stream operator operator<<, the output is the same for ' \ n ' and ' \ n '.
For streams with output buffering (for example, cout, clog), if the buffer flush operation is not performed manually, the output will be refreshed automatically when the buffer is full. However, for cout (relative to the file output stream, etc.), the buffering is generally not obvious. But it is generally a good practice to use Endl instead of ' \ n ' when necessary.
For unbuffered streams (such as standard error output stream cerr), refresh is unnecessary and can be used directly with ' \ n '.
----
Because of the direct input/output and operating system-related, it may be necessary to switch the kernel State/user state, a certain amount of time overhead, frequent operation will greatly reduce the efficiency of the input/output, so the standard library convection input/output operation using buffering. Specifically, a relatively fixed size (buffer) is stored in memory to store temporary input or output. When necessary, the contents of the buffer are copied to the system device and the buffer is emptied, a process called flushing.
A bug in the C + + language