- Use the endl manipulator to insert a newline character into the output stream and flush the buffer. Use the insertion operator with the endl manipulator, as follows:
cout << ... << endl;
- Use the flush member function in the ostream class or the flush manipulator. The flush manipulator does not insert a newline character into the stream before it flushes the buffer. To call the flush member function, use code similar to the following: Use the insertion operator with the flush manipulator as follows:
cout << ... << flush;
- Read from the cin stream or write to the cerr or clog streams. Because these objects share the buffer with cout, each flushes the contents of the buffer before making any changes to it.
- Exit the program to flush all buffers currently in use.
For more information about flushing the cout stream with the endl manipulator, click the following article number to view the article in the Microsoft Knowledge Base:
Article ID: 94227 - Last Review: Jan 5, 2006 - Revision: 1