为什么打不到目标?
#include<stdio.h>#include<stdlib.h>
#define size 4
struct student
{
char name[10];
int num;
int age;
char addr[10];
}stud[size];
void save()
{
int i;
FILE *fp;
if((fp=fopen("student_list.txt","wb"))==NULL)
{
printf("sorry,can not open!!\n");
exit(0);
}
for(i=0;i<size;i++)
{
if(fwrite(&stud[i],sizeof(struct student),1,fp)!=1)
printf("file write wrong\n");
}
fclose(fp);
}
void main()
{
int i;
for(i=0;i<size;i++)
{
scanf("%s%d%d%s",stud[i].name,&stud[i].num,&stud[i].age,stud[i].addr);
}
i=0;
printf("%d",stud[i].num);
save();
}