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的教程中详细讲解,这里也不多讲,日后补充