scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf - input format conversion
格式化输入
#include <stdio.h>
int scanf(const char *format, ...);
int fscanf(FILE *stream, const char *format, ...);
int sscanf(const char *str, const char *format, ...);
//Return: number of input items assigned,
// EOF if input error or end of file before any conversion
scanf用于标准输入
fscanf用于指定的流
sscanf用于指定的字符串
vscanf等
将scanf系列中的参数(…)换成了va_list
#include <stdarg.h>
int vscanf(const char *format, va_list ap);
int vsscanf(const char *str, const char *format, va_list ap);
int vfscanf(FILE *stream, const char *format, va_list ap);
//Return: number of input items assigned,
// EOF if input error or end of file before any conversion
format:scanf指定的参数
转换规范中有三个可选的组件,显示在下面的括号中:
There are three optional components to a conversion specification, shown in square brackets below:
%[∗][fldwidth][m][lenmodifier]convtype
* The optional leading asterisk(*) is used to
suppress(压制) conversion. Input is converted as specified by the rest of the conversion specification, but the result is not stored in an argument.
fldwidth The fldwidth component specifies the maximum field width in characters.
因为标准IO库的内容会在之后讲解C的教程中详细讲解,这里也不多讲,日后补充

本文介绍了C语言中的格式化输入函数,包括scanf、fscanf、sscanf、vscanf、vsscanf和vfscanf。这些函数用于从标准输入、文件流和字符串进行格式化的数据输入。转换规范包含最大字段宽度等组件,详细内容将在后续的C语言教程中进一步讲解。

1万+

被折叠的 条评论
为什么被折叠?



