Microsoft KB Archive/92803

= INFO: Write Function =

Article ID: 92803

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 1.0 Professional Edition

 Microsoft Visual C++ 2.0 Professional Edition

 Microsoft Visual C++ 2.1

 Microsoft Visual C++ 4.0 Standard Edition</li></ul>

 Microsoft Visual C++ 4.1 Subscription</li></ul>

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 1.5 Professional Edition</li></ul>

 Microsoft Visual C++ 1.51</li></ul>

 Microsoft Visual C++ 1.52 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q92803

<div class="notice_section">

<div class="summary_section">

SUMMARY
In an application developed with the Microsoft Foundation Classes (MFC) that uses the CFile class, the Write member function may appear not to correctly process the carriage return-linefeed (CR/LF) combination unless both the carriage return and linefeed are explicitly stated.

For example, the following code CFile file; // ...  file.Write(&quot;Hello\n&quot;, 6); file.Write(&quot;Hello\n&quot;, 6); produces the following output:  <pre class="fixed_text">--- Hello Hello --- However, the following code file.Write(&quot;Hello\n\r&quot;, 7); file.Write(&quot;Hello\n\r&quot;, 7); produces the following output:  <pre class="fixed_text">--- Hello Hello ---

<div class="moreinformation_section">

MORE INFORMATION
When an application uses the CStdioFile class derived from CFile, an application can open a file in either text mode or binary mode. Using a CStdioFile object is the preferred method to place a CR/LF combination into a file. However, if the application must use a CFile object, a CR/LF combination may be explicitly output as demonstrated above.

Additional query words: kbinf 7.00 1.00 1.50 2.00 2.10 2.50 2.51 2.52 3.00 3.10 4.00 4.10

Keywords: kbinfo kbfileio KB92803

-

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

© Microsoft Corporation. All rights reserved.