/* vfscanf example */ #include <stdio.h> #include <stdarg.h> void ReadStuff (FILE * stream, const char * format, ...) { va_list args; va_start (args, format); vfscanf (stream, format, args); va_end (args); } int main () { FILE * pFile; int val; char str[100]; pFile = fopen ("myfile.txt","r"); if (pFile!=NULL) { ReadStuff ( pFile, " %s %d ", str, &val ); printf ("I have read %s and %d", str, val); fclose (pFile); } return 0; } |
vscanf | 将格式化数据读入变量参数列表(function ) |
vsscanf | 将格式化的数据写入字符串(function ) |
fscanf | 将格式化的数据写入字符串(function ) |
scanf | 从stdin读取格式化的数据(function ) |