#include2、tring.h>#include#include#include#defineSTACK_INIT_SIZE10#defineOK1#defineTRUE1#defineFALSE0#defineERROR0structstudent/*定义学生类型,用于存放借出的书籍*/{intcarnum;charlendbook[10];}student[1000];structemploy/*定义职工类型*/{intemploynum;charemployname[1
3、5];intemployage;charemploysex[2];charemployleve[10];longintemploytage;}employ[50];structbook/*定义书的类型*/{intbooknum;charbookname[10];charbookcreat[10];intturefalse;/*用于借书和还书模块判断一本书是否借出的条件*/}book[1000];structcar/*借书卡的数据类型*/{intcarnum;charstudentname[10];intstuden
4、tclass;}car[100];huanbook()/*还书函数*/{FILE*fp,*fp2;/*定义两个文件指针,fp2用于修改数据时设立临时文件用,防止数据遭破坏*/inti,n;intcarnum;charlendbook[10];printf("请你输入你的卡号");scanf("%d",&carnum);fp=fopen("car.txt","r");/*读取卡号记录*/for(i=0;fread(&car[i],sizeof(structcar),1,fp)!=0;i++)/*for循环判断卡号
5、是否存在*/{if(car[i].carnum==carnum)/*卡号存在,进入下一循环*/{n=i;fclose(fp);printf("请输入你要还的书的名字");scanf("%s",lendbook);fp=fopen("record.txt","r");for(i=0;fread(&student[i],sizeof(structstudent),1,fp)!=0;i++)/*判断是否借阅了输入的书*/{if(strcmp(student[i].lendbook,lendbook)==0)/*借阅了
6、该书,进入下一循环,否则出错显示*/{fclose(fp);fp=fopen("record.txt","r");fp2=fopen("bookl.txt","w");for(i=0;fread(&student[i],sizeof(structstudent),1,fp)!=0;i++){if(strcmp(student[i].lendbook,lendbook)==0){continue;/*删除还掉的书的借书记录*/}fwrite(&student[i],sizeof(structstudent),1,fp
7、2);/*写入原来没还的书的记录*/}fclose(fp);fclose(fp2);fp=fopen("record.txt","w");fp2=fopen("bookl.txt","r");for(i=0;fread(&student[i],sizeof(structstudent),1,fp2)!=0;i++){fwrite(&student[i],sizeof(structstudent),1,fp);/*将借书记录信息写回*/}fclose(fp);fclose(fp2);fopen("bookl.txt"
8、,"w");/*清临时文件的记录*/fclose(fp2);fp=fopen("book.txt","r");fp2=fopen("bookl.txt","w");for(i=0;fread(&book[i],sizeof(structbook),1,fp)!=0;i++)/*将书的记录写入临时文件,防止因为修改信息破坏以前的记录*/{if(i==n){bo