资源描述:
《图书管理系统软件》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#include#definePRINT1printf("*****************************************************************************")#definePRINT2printf("图书编号-图书名称-图书作者-图书类型-图书出版社-图书出版时间(年-月-日)-图书数量")#definePRIN
2、T3printf("%d%s%s%s%s%d-%d-%d%d",book[i].num,book[i].name,book[i].writer,book[i].type,book[i].publish,book[i].publish_time.year,book[i].publish_time.month,book[i].publish_time.day,book[i].amount)#definePAGE3#defineMAX300intsum;/*用来记录图书数目(全局变量)*/struct
3、DATE/*定义日期结构体类型*/{intyear;intmonth;intday;};structBOOK/*定义图书结构体类型*/{intnum;/*图书编号*/charname[10];/*图书名称*/charwriter[8];/*图书作者*/chartype[10];/*图书类型*/charpublish[40];/*图书出版社*/structDATEpublish_time;/*图书出版时间*/intamount;/*图书数量*/}book[MAX];/*存放MAX个图书信息记录的结构体
4、数组*//*录入模块*/voidinput(){inti=0,s=MAX;charchoice;printf("****录入图书信息****(最多%d种)",s);printf("*******************************");do{printf("第%d种图书",i+1);printf("★输入图书编号:");scanf("%d",&book[i].num);if(book[i].num==0)break;printf("★输入图书名称:");sca
5、nf("%s",book[i].name);printf("★输入图书作者:");scanf("%s",book[i].writer);printf("★输入图书类型:");scanf("%s",book[i].type);printf("★输入出版社:");scanf("%s",book[i].publish);printf("★出版时间(yyyy-mm-dd):");scanf("%d-%d-%d",&book[i].publish_time.year,&book[i].publ
6、ish_time.month,&book[i].publish_time.day);printf("★输入图书总量:");scanf("%d",&book[i].amount);i++;printf("☆要继续输入吗?(Y/N):");choice=getch();if(choice=='N'
7、
8、choice=='n')break;}while(i9、/*保存模块*/voidsave(){FILE*fp;inti=0;charfilename[10];printf("输入要保存的文件名称:");scanf("%s",filename);/*交互式文件方法*/if((fp=fopen(filename,"wb"))==NULL){printf("****写文件错误!****");}if(fwrite(&book[i],sizeof(book[MAX]),1,fp)!=1)printf("****写文件错误!****");fc
10、lose(fp);}/*读取模块*/voidread(){FILE*fp;inti=0;charfilename[10];printf("输入要保存的文件名称:");scanf("%s",filename);/*交互式文件方法*/if((fp=fopen(filename,"r"))==NULL){printf("****读文件错误!****");}while(!feof(fp)){fread(&book[i],sizeof(book[MAX]),