求助 关于文件
#include "stdlib.h"#include "stdio.h"
#define SIZE 5
main()
{
struct student_type
{
char name[10];
int num;
int age;
float score;
}stud[SIZE];
FILE *fp;
int i;
if((fp=fopen("stulist","wb"))==NULL)
{printf("can not open file.\n");exit(0);}
for(i=0;i<SIZE;i++)
{scanf("%s%d%d%f",stud[i].name,&stud[i].num,&stud[i].age,&stud[i].score);
if(fwrite(&stud[i],sizeof(struct student_type),1,fp)!=1)
{printf("file write error!\n");break;}
}
fclose(fp);
}