When you use Microsoft C/C++ version 7.0, you have several options for I/O programming:
C run-time library direct, unbuffered I/O
The functions _open, _read, _write, and _close, among others, interact directly with the operating system—there is no buffering or formatting. Many existing data management programs use these functions because they are efficient and allow custom buffering schemes. These functions are oriented to the C programmer, but they can be called from C++ programs.
ANSI C run-time library stream I/O
Here the word “stream” refers to the C “stdio” run-time library and does not directly relate to the C++ I/O stream classes. Functions such as fopen, fread, fwrite, and printf do their own buffering before they call the direct functions. These functions are oriented to the C programmer, but they can be called from C++ programs.
Console and port direct I/O
C run-time library functions such as _kbhit are useful in non-Windows applications because they give the programmer direct access to the hardware. There are no C++ class equivalents.
The Microsoft Foundation Class Library
If you are using the Microsoft Foundation Class Library, then you should use the CFile classes for disk I/O, particularly in the Windows environment. This ensures that your applications are portable and extensible.
The Microsoft iostream Class Library
The iostream classes are particularly useful for buffered, formatted text input and output. Use them for unbuffered or binary I/O if you have decided not to use the Microsoft Foundation Classes and if you need a C++ programming interface. Remember that the iostream classes are an object-oriented I/O alternative to C run-time functions such as printf and _read. Their use is not mandatory in C++ programs.
It is possible to use the iostream classes with Microsoft Windows. The string and file streams work without restrictions, but the character-mode stream objects cin, cout, and cerr are inconsistent with the Windows graphical user interface. If you link with the QuickWin Library (see Chapter 8 in Programming Techniques), however, the cin, cout, cerr, and clog objects are assigned to special windows because they are connected to the predefined files stdin, stdout, and stderr. If you are an advanced C++ programmer, you can derive custom stream classes that interact directly with the Windows environment.