主题:这个程序为什么不能将输入的数字写进文件???
#include<stdio.h>
main()
{
int a;
float f;
FILE *fp;
scanf("%d %f",&a,&f);
fp=fopen("yang.dat","w+");
fwrite(&a,sizeof(int),1,fp);
fwrite(&f,sizeof(float),1,fp);
printf("%d %f\n",a,f);
if(fp!=NULL)
{
fscanf(fp,"%d%f",&a,&f);
printf("%d %f",a,f);
fclose(fp);
}
}
main()
{
int a;
float f;
FILE *fp;
scanf("%d %f",&a,&f);
fp=fopen("yang.dat","w+");
fwrite(&a,sizeof(int),1,fp);
fwrite(&f,sizeof(float),1,fp);
printf("%d %f\n",a,f);
if(fp!=NULL)
{
fscanf(fp,"%d%f",&a,&f);
printf("%d %f",a,f);
fclose(fp);
}
}