急!!!问题在哪啊???

来源:百度知道 编辑:UC知道 时间:2024/07/04 09:45:54
/*file.c*/
#include "mine.h"
extern struct CLASS *head;

void save()
{
FILE *fp1,*fp2,*fp3;
struct CLASS *pc;
struct STUD *pst;
struct SUB *psu;
if((fp1=fopen("class.dat","wb"))==NULL){
fprintf(stderr,"Can't open the file:class.dat!");
return;
}
if((fp2=fopen("student.dat","wb"))==NULL){
fprintf(stderr,"Can't open the file:student.dat!");
return;
}
if((fp3=fopen("subject.dat","wb"))==NULL){
fprintf(stderr,"Can't open the file:subject.dat!");
return;
}

for(pc=head;pc!=NULL;pc=pc->cnext){
for(pst=pc->sthead;pst!=NULL;pst=pst->stnext){
for(psu=pst->suhead;psu!=NULL;psu=psu->sunext)
fwrite(psu,sizeof(struct SUB),1,fp3);
fwrite(pst,sizeo

for(pst->suhead=NULL,j=0;j<pst->subjects;j++){
printf("%s",pst->name);printf("%u",pst->number);
printf("%u",pst->subjects);

你所定义的数据结构中的subjects的数据类型如果不是整型的,最好先强制转换一下,

for(pst->suhead=NULL,j=0;j<pst->subjects;j++){
printf("%s",pst->name);printf("%u",pst->number);
printf("%u",pst->subjects);