scanf, fscanf, sscanf
来自cppreference.com
该页由英文版wiki使用Google Translate机器翻译而来。
该翻译可能存在错误或用词不当。鼠标停留在文本上可以看到原版本。你可以帮助我们修正错误或改进翻译。参见说明请点击这里. |
在头文件 <stdio.h> 中定义
|
||
int scanf( const char *format, ... ); |
(1) | |
int fscanf( FILE *stream, const char *format, ... ); |
(2) | |
int sscanf( const char *buffer, const char *format, ... ); |
(3) | |
从各种来源中读取数据,解释它根据
format
,并将结果存储到特定地点.....原文:
Reads data from the a variety of sources, interprets it according to
format
and stores the results into given locations.1)
读取数据从stdin
2)
从文件流
stream
读取数据原文:
reads the data from file stream
stream
3)
null结尾的字符串
buffer
读取数据原文:
reads the data from null-terminated character string
buffer
目录 |
[编辑] 参数
stream | - | 输入文件流中读取
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
buffer | - | 指针指向一个空结束的字符串读取
原文: pointer to a null-terminated character string to read from | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
format | - | 指针指向一个空结束的字符串指定如何读取输入。
格式字符串由空白字符(格式字符串中的任何空白字符消耗所有可用的连续空格字符的输入),非空白字符除了
% (每个这样的格式字符串的字符占用一个相同的字符的输入)转换规范。每个转换规格的格式如下:原文: 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 following format specifiers are available:
原文: pointer to a null-terminated character string specifying how to read the input.
格式字符串由空白字符(格式字符串中的任何空白字符消耗所有可用的连续空格字符的输入),非空白字符除了
% (每个这样的格式字符串的字符占用一个相同的字符的输入)转换规范。每个转换规格的格式如下:原文: 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 following format specifiers are available:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
... | - | 接收参数
|
[编辑] 返回值
成功分配的接收参数,或EOF如果读取失败发生之前,先接收参数被分配数.
原文:
Number of receiving arguments successfully assigned, or EOF if read failure occurs before the first receiving argument was assigned.
[编辑] 示例
本章尚未完成 原因:暂无示例 |
[编辑] 另请参阅
(C99) (C99) (C99) |
stdin,一个文件流或buffer 使用可变参数列表的读取格式的输入 原文: reads formatted input from stdin, a file stream or a buffer using variable argument list (函数) |
得到一个字符串从一个文件流 原文: gets a character string from a file stream (函数) | |
打印格式化输出到stdout,文件流或缓冲区 原文: prints formatted output to stdout, a file stream or a buffer (函数) | |
C++ documentation for scanf, fscanf, sscanf
|