C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
Controlling Binary and Text Modes
                                             Up Contents Index Back
─────C/C++ Language─────────────────────────────────────────────────────────
 
     Most C programs use one or more data files for input and output.
     Data files are ordinarily processed in text mode, in which
     carriage-return/linefeed (CR/LF) combinations are translated
     into a single linefeed (LF) character upon input. LF characters
     are translated to CR/LF combinations upon output.
 
     In some cases, you may want to process files without making these
     translations. In binary mode, CR/LF translations are suppressed.
 
     Standard library routines, such as fopen or _open, give you the
     option of overriding the default mode when you open a particular
     file. You can also change the default mode for an entire program
     from text to binary mode. Do this by linking your program with the
     file BINMODE.OBJ, which is supplied as part of your C compiler
     software. Add the pathname of BINMODE.OBJ to the list of
     object file names when you link your program. For example:
 
          CL MYPROG.C BINMODE.OBJ /LINK /NOE
 
     When you link with BINMODE.OBJ, all files opened in your program
     default to binary mode, with the exceptions of stdin, stdout, and
     stderr. However, linking with BINMODE.OBJ does not force you to
     process all data files in binary mode. You still have the option
     of overriding the default mode when you open the file.
 
     Use the _setmode library function to change the default mode of
     stdin, stdout, or stderr from text to binary, or the default mode
     of _stdaux or _stdprn from binary to text. The _setmode function
     can change the current mode for any file and is primarily used
     for changing the modes of stdin, stdout, stderr, _stdaux, and
     _stdprn, which are not explicitly opened by users.
                                    -♦-