/* vsscanf example */ #include <stdio.h> #include <stdarg.h> void GetMatches ( const char * str, const char * format, ... ) { va_list args; va_start (args, format); vsscanf (str, format, args); va_end (args); } int main () { int val; char buf[100]; GetMatches ( "99 bottles of beer on the wall", " %d %s ", &val, buf); printf ("Product: %s\nQuantity: %d\n", buf, val); return 0; } |
Product: bottles Quantity: 99 |
scanf | 从stdin读取格式化的数据(function ) |
vfscanf | 从流中读取格式化的数据到变量参数列表中(function ) |
sscanf | 从字符串读取格式化的数据(function ) |
fscanf | 从流读取格式化的数据(function ) |