资源描述:
《酒店管理系统C语言版》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#includestructpeopledata{charname[11];charsex[3];intage;intidcard[2];};structdate{intyear;intmonth;intday;inttime;//住宿时间。};typedefstruct{intnumber;charkind;structpeopledatapeople;structdatetime;}rooms;voidadddata(){FILE*fp;roomsroom;chartag,select;inti
2、;do{printf("房间编号:");scanf("%d",&room.number);fflush(stdin);printf("房间类型:");scanf("%c",&room.kind);printf("住宿人员信息:");printf("tt姓名:");fflush(stdin);scanf("%s",room.people.name);fflush(stdin);printf("tt性别:");gets(room.people.sex);printf("tt年龄:");scanf("%d",&room.people.age)
3、;printf("tt请输入身份证号码:");for(i=0;i<2;i++)scanf("%d",&room.people.idcard[i]);printf("入住时间:");printf("tt年:");scanf("%d",&room.time.year);printf("tt月:");scanf("%d",&room.time.month);printf("tt日:");scanf("%d",&room.time.day);printf("入住时长:");scanf("%d",&room.time.time);fflush
4、(stdin);if((fp=fopen("d:\酒店住宿登记表.txt","a"))==NULL){printf("打开文件”酒店住宿登记表“失败,按任意键退出。");exit(0);}else{printf("确定要写入资料吗?(y/n)");scanf("%c",&select);fflush(stdin);if(select=='y'){fwrite(&room,sizeof(rooms),1,fp);if(ferror(fp)!=0){printf("写入资料失败,按任意键退出。");exit(0);}printf("要继续添加
5、?(y/n)");scanf("%c",&tag);fflush(stdin);}else{printf("要继续添加吗?(y/n)");scanf("%c",&tag);fflush(stdin);}}fclose(fp);}while(tag=='y');}voidupdata(){FILE*fp;roomsroom;intnumber,i;printf("请输入要更新的信息的房间编号:");scanf("%d",&number);if((fp=fopen("d:\酒店住宿登记表.txt","r+"))==NULL){printf("
6、打开文件”酒店住宿登记表“失败,按任意键退出。");exit(0);}else{rewind(fp);fread(&room,sizeof(rooms),1,fp);while(!feof(fp)){if(room.number==number)break;fread(&room,sizeof(rooms),1,fp);}if(!feof(fp)){printf("查询成功!");printf("*******************************************************");printf("t—————
7、———————————");printf("tt房间号t房间类型t");printf("tt%dt%c",room.number,room.kind);printf("住宿人员信息:");printf("tt姓名t性别t年龄");printf("tt%st%st%d",room.people.name,room.people.sex,room.people.age);printf("身份证号:");for(i=0;i<2;i++)printf("%d",room.people.idcard[i]);putc
8、har('');printf("入住时间:");printf("%d年%d月%d日