Microsoft KB Archive/83081

= INFO: Endl Flushes the cout Buffer Immediately Upon Execution =

Article ID: 83081

Article Last Modified on 7/5/2005

-

APPLIES TO


 * Microsoft Visual C++ 1.0 Professional Edition
 * Microsoft Visual C++ 1.5 Professional Edition
 * Microsoft Visual C++ 1.51
 * Microsoft Visual C++ 1.52 Professional Edition
 * Microsoft Visual C++ 2.0 Professional Edition
 * Microsoft Visual C++ 2.1
 * Microsoft Visual C++ 4.0 Standard Edition
 * Microsoft Visual C++ 5.0 Enterprise Edition
 * Microsoft Visual C++ 6.0 Enterprise Edition
 * Microsoft Visual C++ 5.0 Professional Edition
 * Microsoft Visual C++ 6.0 Professional Edition
 * Microsoft Visual C++ 6.0 Standard Edition

-



This article was previously published under Q83081





SUMMARY
In these products, 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.



Sample Code
/* Compile options needed: none


 * 1) include 

void main(void) { cout << &quot;This string will be buffered&quot;; cout << &quot;This string will be flushed immediately&quot; <<endl; } For more information on the other methods to flush the cout buffer, please see the following article in the Microsoft Knowledge Base:

94227 INFO: Output Stream cout Is Buffered

Additional query words: 8.00 8.00c 9.00 9.10 CodeView CVW

Keywords: kbinfo kblangcpp KB83081

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.