文件翻译常量File Translation Constants

语法Syntax


#include <stdio.h>  

备注Remarks

这些常数指定转换模式(“b”或“t”)。These constants specify the mode of translation ("b" or "t"). 模式包含在指定访问类型(“r”“w”、“a”、“r+”、“w+”、“a+”)的字符串中。The mode is included in the string specifying the type of access ("r", "w", "a", "r+", "w+", "a+").

转换模式如下所示:The translation modes are as follows:

tt
在文本(已转换)模式下打开。Opens in text (translated) mode. 在这种模式下,输入时,回车/换行 (CR-LF) 组合将转换为单一的换行 (LF);输出时,LF 字符将转换为 CR-LF 组合。In this mode, carriage-return/linefeed (CR-LF) combinations are translated into single linefeeds (LF) on input, and LF characters are translated into CR-LF combinations on output. CTRL+Z 也将在输入时解释为文件尾字符。Also, CTRL+Z is interpreted as an end-of-file character on input. 在打开以进行读取或读取/写入的文件中,fopen 将检查文件末尾的 Ctrl+Z 并在可能的情况下将其移除。In files opened for reading or reading/writing, fopen checks for CTRL+Z at the end of the file and removes it, if possible. 这样做是因为,使用 fseekftell 函数在以 Ctrl+Z 结尾的文件中移动时,可能导致 fseek 在文件末尾附近错误操作。This is done because using the fseek and ftell functions to move within a file ending with CTRL+Z may cause fseek to behave improperly near the end of the file.

备注

“t”选项不是 fopenfreopen 的 ANSI 标准的一部分。The t option is not part of the ANSI standard for fopen and freopen. 它是一个 Microsoft 扩展,不应在需要 ANSI 可移植性的地方使用。It is a Microsoft extension and should not be used where ANSI portability is desired.

bb
在二进制(未转换)模式下打开。Opens in binary (untranslated) mode. 禁止上述的转换。The above translations are suppressed.

如果在 mode 中未给出 t 或 b,则转换模式由默认模式变量 _fmode 定义。If t or b is not given in mode, the translation mode is defined by the default-mode variable _fmode. 有关使用文本和二进制模式的详细信息,请参阅文本和二进制模式文件 I/OFor more information about using text and binary modes, see Text and Binary Mode File I/O.

另请参阅See Also

_fdopen、_wfdopen _fdopen, _wfdopen
fopen、_wfopen fopen, _wfopen
freopen、_wfreopen freopen, _wfreopen
_fsopen、_wfsopen _fsopen, _wfsopen
全局常量Global Constants