struct student { //学生结构体
char name[LENGTH];
char num[LENGTH];
int chinese;
int math;
int english;
}stu;
void inputScore() //(B)录入学生成绩//
{
FILE *file;
file=fopen("E:\\stu_score.dat","ab");
if(file==FAIL){
printf("File Is Not Exist.\n");
file=fopen("E:\\stu_score.dat","wb+");
printf("File Is Set Up.\n");
file=fopen("E:\\stu_score.dat","ab");
}
printf("Intput name:");
gets(stu.name);
printf("Intput num:");
gets(stu.num);
printf("Intput chinese:");
scanf("%d",&stu.chinese);
printf("Intput math:");
scanf("%d",&stu.math);
printf("Intput english:");
scanf("%d",&stu.english);
fwrite(&stu,sizeof(student),1,file);
fclose(file);
}子函数如图 但是不知道为什么储存不了 求解!!
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream);
第ä¸ä¸ªåæ°ä¸è½ä¸ºç»æä½åé
ä½ å¯ä»¥æstuä¸çåéä¿åå°æ°ç»ä¸åå«åå ¥