📅  最后修改于: 2020-09-26 15:53:51             🧑  作者: Mango
int scanf( const char* format, ... );
scanf()
函数从stdin
读取数据,并将值存储到各个变量中。
它在
#include
int main ()
{
FILE *fp;
char name[50];
int age;
fp = fopen("example.txt","w");
fprintf(fp, "%s %d", "Tim", 31);
fclose(fp);
fp = fopen("example.txt","r");
scanf(fp, "%s %d", name, &age);
fclose(fp);
printf("Hello %s, You are %d years old\n", name, age);
return 0;
}
运行该程序时,可能的输出为:
Hello Tim, You are 31 years old