这是书上的例子怎么全是错???
#include<stdio.h>#define SIZE 3
typedef struct student
{
char name[10];
int num;
int age;
char addr[15];
}stud[SIZE];
void save()
{
FILE *fp;
int i;
if(fp=fopen("stud_list","wb")==NULL)
{
printf("Can not open the list\n");
return;
}
for(i=0;i<SIZE;i++)
if(fwrite(&stud[i],sizeof(struct student),1,fp)!=1)
printf("File write error\n");
fclose(fp);
}
int main(int argc,char *argv[])
{
int i;
puts("Please input students information,seris are name,num,age and addr");
for(i=0;i<SIZE;i++)
scanf("%s%d%d%s",&stud[i].name,&stud[i].num,&stud[i].age,&stud[i].addr);
save();
return 0;
}