INF: Endl Flushes the cout Buffer Immediately Upon Execution

ID Number: Q83081

7.00

MS-DOS

Summary:

In the Microsoft C/C++ Compiler version 7.0, the cout class uses a

buffering system for data that may not be flushed immediately. Because

cout usually handles small messages, several messages are usually

needed to fill the buffer, which will cause the data to be written to

the standard output handle. In some cases, this can cause considerable

delay when writing output to the screen during a debugging session.

This problem can be avoided, however, by using the endl manipulator.

When appended to the end of a cout call, the endl manipulator inserts

a newline character and then flushes the buffer.

More Information:

Sample Code

-----------

/* Compile options needed: /f /Od /Zi

*/

void main()

{

cout << "This string will be buffered";

cout << "This string will be flushed immediately" <<endl;

}

Additional reference words: CodeView CVW 7.00