/* vscanf example */ #include <stdio.h> #include <stdarg.h> void GetMatches ( const char * format, ... ) { va_list args; va_start (args, format); vscanf (format, args); va_end (args); } int main () { int val; char str[100]; printf ("Please enter a number and a word: "); fflush (stdout); GetMatches (" %d %99s ", &val, str); printf ("Number read: %d\nWord read: %s\n", val, str); return 0; } |
Please enter a number and a word: 911 airport Number read: 911 Word read: airport |
scanf | 从stdin读取格式化的数据(function ) |
vfscanf | 从流中读取格式化的数据到变量参数列表中(function ) |
vsscanf | 从字符串中读取格式化的数据到变量参数列表中(function ) |
fscanf | 从流读取格式化的数据(function ) |