wo de zhe ge lian biao zen mo bao cun qiu chen xu..

问题描述:

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 ...
1个回答 分类:综合 2014-09-23

问题解答:

我来补答
你在搞笑吧?文件指针哪来的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");
}
 
 
展开全文阅读
剩余:2000
下一页:请说清为什么