📅  最后修改于: 2020-09-25 08:41:39             🧑  作者: Mango
vscanf() 函数在
int vscanf( const char* format, va_list vlist );
vscanf() 函数从stdin读取数据,并将值存储到vlist定义的各个位置。
#include
#include
void read( const char * format, ... )
{
va_list args;
va_start (args, format);
vscanf (format, args);
va_end (args);
}
int main ()
{
float marks;
char subj[50];
printf("Enter subject's name and marks obtained: ");
read(" %s %f", subj,&marks);
printf("You scored %.2f in %s\n", marks, subj);
return 0;
}
运行该程序时,可能的输出为:
Enter subject's name and marks obtained: math 12
You scored 12.00 in math