fclose(sfp); return 0; }
int reader::reader_mod() //定义修改读者的函数 {
FILE *sfp; int i,num,s,n; page_title();
cout<<\☆修改读者☆\ if((sfp=fopen(\ {
cout<<\无法打开文件. \ }
for(i=0;i fread(&stud[i],sizeof(stud[i]),1,sfp); } fclose(sfp); cout< for(i=0,s==-1;i if(stud[i].num==num) { cout<<\名字:\ cout<<\学号: \ cout<<\年级: \ cout<<\班级: \ cout<<\性别: \ cout<<\书名: \ cout<<\借书日期: \ cout<<\可借天数: \ cout<<\ cout<<\是否确定修改该读者(1为是,0为否): \ cin>>s; if(s==1) { page_title(); cout<<\请重新输入读者的信息.<<<\ do { cout<<\请输入一个新的学号(学号从1001开始,但必须不同于已存在的学号):\ cin>>stud[i].num; . . . . for(n=0;n if(stud[i].num==stud[n].num&&n!=i) { cout<<\该学号已存在.\ } } }while(stud[i].num==stud[n].num); cout<<\名字: \ cin>>stud[i].name; cout<<\年级: \ cin>>stud[i].grade; cout<<\班级: \ cin>>stud[i].clas; cout<<\性别: \ cin>>stud[i].sex; cout<<\书名: \ cin>>stud[i].book_name; cout<<\借书日期: \ cin>>stud[i].date; cout<<\可借天数: \ cin>>stud[i].avai_days; } else if(s==0) { return 0; } } } if(s==-1) { cout<<\该读者不存在. \ } if((sfp=fopen(\ { cout<<\无法打开文件. \ } for(i=0;i fwrite(&stud[i],sizeof(stud[i]),1,sfp); } fclose(sfp); return 0; } . . . .int book::book_out() //定义借书函数 { FILE *bfp,*sfp; int id,i,s,l,num, avaiday; char dates[10]; page_title(); cout<<\☆借书☆\\n\ cout<<\请输入书号:\ cin>>id; if((bfp=fopen(\ cout<<\无法打开文件.\\n\ for(i=0;i fread(&books[i],sizeof(books[i]),1,bfp); } fclose(bfp); for(i=0;i if(id==books[i].id&&books[i].id!=0) { system(\ page_title(); cout<<\☆书的信息☆\\n\ cout<<\书名: \ cout<<\书号: \ cout<<\作者: \ cout<<\价格: \ cout<<\总存量: \ cout<<\现存量: \ cout<<\出版社: \ cout<<\出版时间: \ cout<<\读者: \ cout<<\读者学号: \ cout<<\ if((sfp=fopen(\ { cout<<\无法打开文件. \ } for(l=0;l fread(&stud[l],sizeof(stud[l]),1,sfp); } fclose(sfp); cout<<\请输入你的学号:\\n\ . . . . A: cin>>num; for(l=0;l if(stud[l].getnum()==num) { if(books[i].store!=0) { cout<<\请输入可借的天数:\\n\ cin>>avaiday; stud[l].setavaiday(avaiday); cout<<\请输入借书日期:\\n\ cin>>dates; stud[l].setdate(dates); if((bfp=fopen(\ { cout<<\无法打开文件.\ } for(s=0;s fread(&books[s],sizeof(books[s]),1,bfp);fclose(bfp); if(books[s].id==books[i].id) { books[s].store--; books[s].borr_num=stud[l].getnum(); strcpy(books[s].borrower,stud[l].getname()); strcpy(stud[l].getbook_name(),books[s].name); cout<<\你已经借了这本书. \ sfp=fopen(\ for(l=0;l fwrite(&stud[l],sizeof(stud[l]),1,sfp); } fclose(sfp); } } } } else if(stud[l].getnum()!= num) { cout<<\对不起,该学号是错误的,请再输入一遍:\\n\ goto A; } } bfp=fopen(\ . . . . for(s=0;s fwrite(&books[s],sizeof(books),1,bfp); } fclose(bfp); } } } int book::book_in() //定义还书函数 { page_title(); cout<<\☆还书☆\\n\ int i,num,id,n; char no[]={\ FILE *bfp,*sfp; if((sfp=fopen(\ { cout<<\无法打开文件. \ } for(i=0;i fread(&stud[i],sizeof(stud[i]),1,sfp); } fclose(sfp); cout<<\请输入你的学号:\ BEFOR: cin>>num; for(i=0;i if(stud[i].getnum()==num&&stud[i].getnum()!=0) { system(\ page_title(); cout<<\☆读者信息☆\\n\ cout<<\名字:\ cout<<\学号: \ cout<<\年级: \ cout<<\班级: \ cout<<\性别: \ cout<<\书名: \ cout<<\借书日期: \ cout<<\可借天数: \ cout<<\ if((bfp=fopen(\ { . . . .