输入和输出Input and Output

I/O 函数在文件和设备中读取和写入数据。The I/O functions read and write data to and from files and devices. 文件 I/O 操作在文本模式或二进制模式下进行。File I/O operations take place in text mode or binary mode. Microsoft 运行库有三种类型的 I/O 函数:The Microsoft run-time library has three types of I/O functions:

  • 流 I/O 函数将数据视为单个字符的流。Stream I/O functions treat data as a stream of individual characters.

  • 低级别 I/O 函数将为低于流 I/O 提供的操作的低级别操作直接调用操作系统。Low-level I/O functions invoke the operating system directly for lower-level operation than that provided by stream I/O.

  • 控制台和端口 I/O 函数直接在控制台(键盘和屏幕)或 I/O 端口(如打印机端口)中进行读取和写入。Console and port I/O functions read or write directly to a console (keyboard and screen) or an I/O port (such as a printer port).

    备注

    由于流函数将进行缓冲而底层函数不会这样,因此这两种类型的函数通常是不兼容的。Because stream functions are buffered and low-level functions are not, these two types of functions are generally incompatible. 若要处理特定文件,请以独占方式使用流函数或底层函数。For processing a particular file, use either stream or low-level functions exclusively.

另请参阅See Also

按类别分的运行时例程Run-Time Routines by Category