回复 4楼 ehszt
我用了啊,但是把原数据擦掉了
void saving(int k)//存款
{
double cash;
Use buf,p;
FILE *fp;
fp=fopen("file.dat","rb");
fread(&buf,sizeof(Use),1,fp);
fseek(fp,(long)(k-1)*Len,SEEK_SET);
printf("\n原先有%lf",buf.cash);
printf("请输出你要存入的金额:");
scanf("%lf",&cash);
buf.cash+=cash;
printf("\n存入后%lfs",buf.cash);
fclose(fp);
printf("%s %s %s %lf %hd %d",buf.number,buf.name,buf.password,buf.cash,buf.mark,buf.k);
p=buf;
fp=fopen("file.dat","wb");
fseek(fp,(long)k*Len,SEEK_SET);
fwrite(&p,sizeof(Use),1,fp);
fclose(fp);
}