void save (struct stu *head)
{
FILE *fp,*fpp;
if (((fp=fopen (filenameB,"at"))==NULL)||((fpp=fopen (filename,"at"))==NULL))
{
printf ("文件创建失败,请按任意键继续...");
getch();
system( "cls ");
}
while (head!=NULL) // 循环将信息写入文件
{
fwrite(head,sizeof (struct stu ),1,fp);
fprintf(fpp," 学号 姓名 %s 等级 %s 等级 %s 等级 总分 平均分
",sub1,sub2,sub3);
fprintf(fpp,"%d %s %.1f %c %.1f %c %.1f %c %.1f %.2f
",head->num,head->name,head->s[0],head->dj[0],head->s[1],head->dj[1],head->s[2],head->dj[2],head->sum,head->ave);
head=head->next ;
}
fclose (fp);
fclose(fpp);
printf ("
成绩已保存完毕,感谢您的使用!请按任意键继续...");
getch ();
system( "cls ");
}