This documentation is archived and is not being maintained.

Text and Binary Mode File I/O

File I/O operations take place in one of two translation modes, text or binary, depending on the mode in which the file is opened. Data files are usually processed in text mode. To control the file translation mode, you can:

  • Retain the current default setting and specify the alternative mode only when you open selected files.
  • Change the default translation mode directly by setting the global variable _fmode in your program. The initial default setting of _fmode is _O_TEXT, for text mode.

When you call a file-open function such as _open, fopen, freopen, or _fsopen, you can override the current default setting of _fmode by specifying the appropriate argument to the function. The stdin, stdout, and stderr streams always open in text mode by default; you can also override this default when opening any of these files. Use _setmode to change the translation mode using the file descriptor after the file is open.

See Also

Input and Output | Run-Time Routines by Category | Run-Time Routines and .NET Framework Equivalents