wo de zhe ge lian biao zen mo bao cun qiu chen xu..typedef struct zhigong{\x05int num;\x05char name[8];\x05char xb[2];\x05char bm[6];\x05float jbgz;\x05float jj;\x05float ylbx;\x05float zfjj;\x05float yfgz;\x05struct zhigong *next;}zg;wo yi shu ru le

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 02:35:06

wo de zhe ge lian biao zen mo bao cun qiu chen xu..typedef struct zhigong{\x05int num;\x05char name[8];\x05char xb[2];\x05char bm[6];\x05float jbgz;\x05float jj;\x05float ylbx;\x05float zfjj;\x05float yfgz;\x05struct zhigong *next;}zg;wo yi shu ru le
wo de zhe ge lian biao zen mo bao cun qiu chen xu..
typedef struct zhigong
{
\x05int num;
\x05char name[8];
\x05char xb[2];
\x05char bm[6];
\x05float jbgz;
\x05float jj;
\x05float ylbx;
\x05float zfjj;
\x05float yfgz;
\x05struct zhigong *next;
}zg;
wo yi shu ru le xin xi zen mo bao cun a wo ji yong ..
/*保存模块*/
void bao_cun(zg *head)
{
\x05FILE *fp;
zg s;
char save[10];
printf("请输入保存的文件名:如c:\\score\n");
scanf("%s",save);
if((fp=fopen(save,"wb"))==NULL)
{
printf("不能建立%s文件,返回菜单.\n");
return;
}
printf("\n保存文件中.\n");
while(!feof(fp))
{
fwrite(s,sizeof(zg),1,fp);
fp=fp->next;
}
fclose(fp);
printf("保存文件成功!\n");
return;
}
zhe shi wo bian de ,ni kan neng gai cheng bao cun de ma ...

wo de zhe ge lian biao zen mo bao cun qiu chen xu..typedef struct zhigong{\x05int num;\x05char name[8];\x05char xb[2];\x05char bm[6];\x05float jbgz;\x05float jj;\x05float ylbx;\x05float zfjj;\x05float yfgz;\x05struct zhigong *next;}zg;wo yi shu ru le
你在搞笑吧?文件指针哪来的next?而且你是写入,不是读取,feof完全没有用处.改成这样:
void bao_cun(zg *head)
{
FILE *fp;
char save[10];
printf("请输入保存的文件名:如c:\\score\n");
scanf("%s",save);
if((fp=fopen(save,"wb"))==NULL)
{
printf("不能建立%s文件,返回菜单.\n");
return;
}
printf("\n保存文件中.\n");
while(head!=null)
{
fwrite(head,sizeof(zg),1,fp);
head=head->next;
}
fclose(fp);
printf("保存文件成功!\n");
}