Microsoft KB Archive/68944

{|
 * width="100%"|

Output to stdprn Is in Binary (Untranslated) Mode

 * }

Q68944

-

The information in this article applies to:


 * The C Run-Time (CRT), included with:
 * Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
 * Microsoft C for OS/2, versions 6.0, and 6.0a
 * Microsoft C/C++ for MS-DOS, version 7.0
 * Microsoft Visual C++, versions 1.0, 1.5, 1.51, 1.52

-

SUMMARY
The 16-bit C start-up code automatically opens five files for a program's use. The &quot;stdprn&quot; file (PRN device) is opened in binary mode, which is important to remember when printing to printers that require a carriage return/line feed combination to end a line (for example, some laser printers). In those cases, you do one of the following:


 * Change your output routines to send a CR/LF pair (\n\r).
 * Reopen stdprn in text mode so that the translation is handled by the run-time library.
 * Change the mode of the file to O_TEXT. You must remember to flush the buffer before doing this.

MORE INFORMATION
The following is a code fragment that illustrates each method:

#include  void main(void) {  FILE *txtprn; fprintf(stdprn, &quot;untranslated\n&quot;);       // Standard mode fprintf(stdprn, &quot;CRLF pair added \n\r&quot;); // Method 1 txtprn=freopen(&quot;PRN&quot;, &quot;wt&quot;,stdprn);      // Method 2 fprintf(txtprn, &quot;translated\n&quot;); fflush(stdprn);                          // Flush the buffer first setmode(fileno(stdprn), O_TEXT);         // Method 3 fprintf(stdprn, &quot;translated\n&quot;); } Additional query words: kbinf 5.10 6.00 6.00a 6.00ax 7.00 1.00 1.50
 * 1) include 
 * 2) include 

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT