scanf, fscanf, sscanf
来自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. |
| Defined in header <stdio.h>
|
||
| int scanf( const char *format, ... ); |
(1) | |
| (2) | ||
| int sscanf( const char *buffer, const char *format, ... ); |
(3) | |
从各种来源中读取数据,解释它根据
format,并将结果存储到特定地点.....Original:
Reads data from the a variety of sources, interprets it according to
format and stores the results into given locations.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)
读取数据从stdin
Original:
reads the data from stdin
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)
从文件流
stream读取数据Original:
reads the data from file stream
streamThe 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)
null结尾的字符串
buffer读取数据Original:
reads the data from null-terminated character string
bufferThe 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.
目录 |
[编辑] 参数
| stream | - | 输入文件流中读取
Original: input file stream to read from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| buffer | - | 指针指向一个空结束的字符串读取
Original: pointer to a null-terminated character string to read from The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| format | - | 指针指向一个空结束的字符串指定如何读取输入。
格式字符串由空白字符(格式字符串中的任何空白字符消耗所有可用的连续空格字符的输入),非空白字符除了
%(每个这样的格式字符串的字符占用一个相同的字符的输入)转换规范。每个转换规格的格式如下:Original: The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.
下面的格式说明符
Original: The following format specifiers are available: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.
Original: pointer to a null-terminated character string specifying how to read the input.
格式字符串由空白字符(格式字符串中的任何空白字符消耗所有可用的连续空格字符的输入),非空白字符除了
%(每个这样的格式字符串的字符占用一个相同的字符的输入)转换规范。每个转换规格的格式如下:Original: The format string consists of whitespace characters (any single whitespace character in the format string consumes all available consecutive whitespace characters from the input), non-whitespace characters except % (each such character in the format strings consumes exactly one identical character from the input) and conversion specifications. Each conversion specification has the following format:The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.
下面的格式说明符
Original: The following format specifiers are available: The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions.
The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ... | - | 接收参数
Original: receiving arguments The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
[编辑] 返回值
成功分配的接收参数,或EOF如果读取失败发生之前,先接收参数被分配数.
Original:
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned.
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.
[编辑] 为例
| 本节是不完整的 原因: no example |
[编辑] 另请参阅
| (C99) (C99) (C99) |
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. (函数) |
| 得到一个字符串从一个文件流 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. (函数) | |
| 打印格式化输出到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. (函数) | |
| C++ documentation for scanf, fscanf, sscanf
| |