#include <stdio.h>
FILE *stream;
void main(void)
{
long l;
float fp;
char s [81];
char c;
stream = fopen(“fscanf.out”,“w +”);
if(stream == NULL)
printf(“文件fscanf.out未打开\ n”);
else
{
fprintf(stream,“%s%ld%f%c”,“a-string”
,65000,3.14159,‘x’);//格式化输入
/ *设置指向文件开头的指针:
fseek(stream,0L,SEEK_SET);
/ *从文件中读取数据:* /
fscanf(stream,“%s”,s);
fscanf(stream,“%ld”,&l);
fscanf(stream,“%f”,&fp);
fscanf(stream,“%c”,&c);
/ *输出数据读取:* /
printf(“%s \ n”,s);
printf(“%ld \ n”,l);
printf(“%f \ n”,fp);
printf(“%c \ n”,c);
fclose(stream);
}
}