C语言保存的程序重新打开,C语言中,如何让关闭的后再打开的程序再次读取出文件内的内容...

相关代码如下,请问是哪里出了问题呢?

void SaveStudent()

{

FILE *fp;

node *p=head;

fp=fopen(fname,"wb");

while (p!=NULL)

{

fwrite(&p->stu,sizeof(node),1,fp);

p=p->next;

}

fclose(fp);

printf ("ok\n");

system("pause"); //暂停

system("cls"); //清屏

}

void ReadStudent()

{

FILE *fp;

node *p=head;

int i=0,n=CountStudent();

if ((fp=fopen(fname,"rb"))==NULL)

{

printf ("文件尚未创建\n");

return;

}

for (i=0;i

{

fscanf(fp,"%ld %s %.1f %d %s %d %d %d %s %ld %s\n",&p->stu.num,p->stu.name,&p->stu.score,&p->stu.age,p->stu.sex,&p->stu.year,&p->stu.month,&p->stu.day,p->stu.adress,&p->stu.call,p->stu.e_mail);

p=p->next;

}

fclose(fp);

PrintStudent();

system("pause"); //暂停

system("cls"); //清屏

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值