Microsoft KB Archive/101185: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
Line 58: Line 58:
<br />
<br />
Because the cout text stream is buffered, text from a DLL may not appear correct relative to text from the application. To correct this problem, always use the endl manipulator when outputting text with cout. Below is an example:
Because the cout text stream is buffered, text from a DLL may not appear correct relative to text from the application. To correct this problem, always use the endl manipulator when outputting text with cout. Below is an example:
<pre class="codesample">  cout &lt;&lt; &quot;Hello World&quot; &lt;&lt; endl;
<pre class="codesample">  cout &lt;&lt; "Hello World" &lt;&lt; endl;
                 </pre>
                 </pre>
The endl manipulator inserts a newline character and then flushes the stream buffer. This ensures that text displayed from the application and DLL is synchronized.
The endl manipulator inserts a newline character and then flushes the stream buffer. This ensures that text displayed from the application and DLL is synchronized.

Revision as of 09:19, 20 July 2020

Knowledge Base


Cout and endl can be used in an application and in a Dynamic Link Library (DLL) to display information

Article ID: 101185

Article Last Modified on 12/9/2005



APPLIES TO

  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 1.5 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • 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
  • Microsoft Visual C++ .NET 2003 Standard Edition
  • Microsoft Visual C++ .NET 2002 Standard Edition
  • Microsoft Visual C++ 2005 Express Edition



This article was previously published under Q101185

SUMMARY

The standard output stream (cout) can be used in an application or Dynamic- Link Library (DLL) to display information. When using cout in an application and a DLL simultaneously, special care is needed to ensure that the text display is synchronized.

Because the cout text stream is buffered, text from a DLL may not appear correct relative to text from the application. To correct this problem, always use the endl manipulator when outputting text with cout. Below is an example:

   cout << "Hello World" << endl;
                

The endl manipulator inserts a newline character and then flushes the stream buffer. This ensures that text displayed from the application and DLL is synchronized.

Keywords: kbinfo kblangcpp KB101185