C-style file input/output
来自cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
CI / O的C + +标准库的子集实现C-风格的流输入/输出操作。
<cstdio>
头提供了通用的文件操作狭窄和多字节字符的输入/输出功能,支持和供应职能和<cwchar>
头提供的功能与宽字符输入/输出功能. Original:
The C I/O subset of the C++ standard library implements C-style stream input/output operations. The
<cstdio>
header provides generic file operation support and supplies functions with narrow and multibyte character input/output capabilities, and the <cwchar>
header provides functions with wide character input/output capabilities. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ç流std::FILE类型的对象只能访问和操纵通过指针的类型std::FILE*(注:有可能创建一个本地对象类型std::FILE有效的FILE*提领和复制,使用该副本的地址I / O功能是未定义的行为)。每个C流与外部物理设备(文件,标准输入流,打印机,串行端口等).
Original:
C streams are objects of type std::FILE that can only be accessed and manipulated through pointers of type std::FILE* (Note: while it may be possible to create a local object of type std::FILE by dereferencing and copying a valid FILE*, using the address of such copy in the I/O functions is undefined behavior). Each C stream is associated with an external physical device (file, standard input stream, printer, serial port, etc).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
Ç流可以被用于两个未格式化和格式化的输入和输出。他们是语言环境敏感的,必要时可进行宽/多字节转换。与C + +流,每个流与自己的地区,所有的C流访问相同的区域对象:一个最近安装的std::setlocale.
Original:
C streams can be used for both unformatted and formatted input and output. They are locale-sensitive and may perform wide/multibyte conversions as necessary. Unlike C++ streams, where each stream is associated with its own locale, all C streams access the same locale object: the one most recently installed with std::setlocale.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
除了特定的信息系统需要访问的设备(如POSIX文件描述符),每一个C的流对象持有以下
Original:
Besides the system-specific information necessary to access the device (e.g. a POSIX file descriptor), each C stream object holds the following:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1)
字符宽度:窄或宽的
Original:
Character width: narrow or wide
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
缓冲状态:无缓冲,行缓冲,全缓冲.
Original:
Buffering state: unbuffered, line-buffered, fully buffered.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3)
的缓冲液,其中可被一个外部的,用户提供缓冲区.
Original:
The buffer, which may be replaced by an external, user-provided buffer.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
4)
I / O模式:输入,输出,或更新(包括输入和输出).
Original:
I/O mode: input, output, or update (both input and output).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
5)
二进制/文本模式指示灯.
Original:
Binary/text mode indicator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
6)
文件的状态指示灯.
Original:
End-of-file status indicator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
7)
错误状态指示灯.
Original:
Error status indicator.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
8)
文件位置指示器(一个对象类型std::fpos_t),,,宽字符流的解析状态,包括(类型的对象mbstate_t)
Original:
File position indicator (an object of type std::fpos_t), which, for wide character streams, includes the parse state (an object of type mbstate_t).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[编辑] 功能
Original: File access The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
打开一个文件 Original: opens a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
打开一个现有的流用不同的名称 Original: open an existing stream with a different name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
关闭一个文件 Original: closes a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
实际的文件同步输出流 Original: synchronizes an output stream with the actual file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
宽字符I / O和窄字符之间切换文件流I / O Original: switches a file stream between wide character I/O and narrow character I/O The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
设置文件流的缓冲区 Original: sets the buffer for a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
设置文件流的缓冲区,其大小 Original: sets the buffer and its size for a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Direct input/output The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
从文件读取 Original: reads from a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
写入到一个文件中 Original: writes to a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Unformatted input/output The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
Original: Narrow character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
从文件流中获取一个字符 Original: gets a character from a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
得到一个字符串从一个文件流 Original: gets a character string from a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
将一个字符写入一个文件流 Original: writes a character to a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
将一个字符串写入一个文件流 Original: writes a character string to a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
从stdin中读取一个字符 Original: reads a character from stdin The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
从stdin读取一个字符的字符串 Original: reads a character string from stdin The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
将一个字符写入stdout Original: writes a character to stdout The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
写一个字符串stdout Original: writes a character string to stdout The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
把一个字符到一个文件流 Original: puts a character back into a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Wide character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
得到一个宽字符的文件流 Original: gets a wide character from a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
获取宽字符串从文件流 Original: gets a wide string from a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
一个宽字符写入一个文件流 Original: writes a wide character to a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
宽字符串写入一个文件流 Original: writes a wide string to a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
读取一个字符stdin Original: reads a wide character from stdin The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
写一个宽字符stdout Original: writes a wide character to stdout The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
把一个宽字符到一个文件流 Original: puts a wide character back into a file stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Formatted input/output The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
Original: Narrow/multibyte character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
stdin,文件流或缓冲区的读取格式的输入 Original: reads formatted input from stdin, a file stream or a buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
(C++11) (C++11) (C++11) |
stdin,一个文件流或buffer 使用可变参数列表的读取格式的输入 Original: reads formatted input from stdin, a file stream or a buffer using variable argument list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
(C++11) |
打印格式化输出到stdout,文件流或缓冲区 Original: prints formatted output to stdout, a file stream or a buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
打印格式化的输出stdout,一个文件流或buffer 使用可变参数列表 Original: prints formatted output to stdout, a file stream or a buffer using variable argument list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Wide character The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
stdin,文件流或缓冲区读取格式的宽字符输入 Original: reads formatted wide character input from stdin, a file stream or a buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
(C++11) (C++11) (C++11) |
stdin,的文件stream 或使用可变参数列表的缓冲区读取格式的宽字符输入 Original: reads formatted wide character input from stdin, a file stream or a buffer using variable argument list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
打印格式化宽字符输出到stdout,文件流或缓冲区 Original: prints formatted wide character output to stdout, a file stream or a buffer The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
打印格式化宽字符输出到stdout,的文件stream 或使用可变参数列表的缓冲区 Original: prints formatted wide character output to stdout, a file stream or a buffer using variable argument list The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: File positioning The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
返回当前的文件指针位置 Original: returns the current file position indicator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
获取文件位置指示器 Original: gets the file position indicator The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
在一个文件中的文件位置指示符移动到特定的位置 Original: moves the file position indicator to a specific location in a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
在一个文件中的文件位置指示符移动到特定的位置 Original: moves the file position indicator to a specific location in a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
移动的文件,在一个文件中的开始位置指示器 Original: moves the file position indicator to the beginning in a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Error handling The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
清除错误 Original: clears errors The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
检查文件结束 Original: checks for the end-of-file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
检查文件错误 Original: checks for a file error The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
显示一个字符串相应的电流误差stderr Original: displays a character string corresponding of the current error to stderr The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
Original: Operations on files The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | |
删除一个文件 Original: erases a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
重命名文件 Original: renames a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
创建并打开一个临时的,自动删除文件 Original: creates and opens a temporary, auto-removing file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) | |
返回一个唯一的文件名 Original: returns a unique filename The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (函数) |
[编辑] 类型
Defined in header
<cstdio> | |
类型
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
FILE | 类型,能够保持一个CI / O流控制所需的所有信息
Original: type, capable of holding all information needed to control a C I/O stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
fpos_t | 的类型,能够唯一地指定在一个文件中的位置
Original: type, capable of uniquely specifying a position in a file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[编辑] 宏
Defined in header
<cstdio> | |
stdin stdout stderr |
表达的类型FILE*与 与错误输出流的类型的输出streamFILE*expression的类型 的的输入streamFILE*expression的 Original: expression of type FILE* associated with the input stream expression of type FILE* associated with the output stream expression of type FILE* associated with the error output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
EOF |
整型常量表达式的类型int和负价值 Original: integer constant expression of type int and negative value The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
FOPEN_MAX |
可以同时打开的文件数 Original: number of files that can be open simultaneously The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
FILENAME_MAX |
大小需要的为char数组以保存最长的支持文件名 Original: size needed for an array of char to hold the longest supported file name The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
BUFSIZ |
std::setbuf所用的缓冲区的大小 Original: size of the buffer used by std::setbuf The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
_IOFBF _IOLBF _IONBF |
到std::setbuf的参数,表示完全缓冲的I /O argumentstd::setbuf指示线表示非缓冲I / O缓冲的I /O argumentstd::setbuf Original: argument to std::setbuf indicating fully buffered I/O argument to std::setbuf indicating line buffered I/O argument to std::setbuf indicating unbuffered I/O The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
SEEK_SET SEEK_CUR SEEK_END |
参数为std::fseek表明寻求从开始的file argumentstd::fseek 寻求从文件末尾寻求从当前文件positionstd::fseekargument的 Original: argument to std::fseek indicating seeking from beginning of the file argument to std::fseek indicating seeking from the current file position argument to std::fseek indicating seeking from end of the file The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
TMP_MAX |
唯一的文件名,可以产生std::tmpnam最大数目 Original: maximum number of unique filenames that can be generated by std::tmpnam The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |
L_tmpnam |
大小需要一个char数组来保存结果的std::tmpnam Original: size needed for an array of char to hold the result of std::tmpnam The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (宏不变) |