资源描述:
《【精品】超市管理程序.doc》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、#include#include#include#includestructThing{intid;charnanie[30];charproduce[30];intnumber;floatprice;chartype[30];);voidtianjia();voidshanchu();voidxiugai();voidchaxun();voidchazhao();voidliulan();voidtuichu();voidinitialization(){FILE*f
2、p;structThingi={1,”牛奶”,”辽宁”,1200,3};fp=fopen("Thing.dat恶”,”w”);if(fp==NULL){printf(Mttt系统错误,请重试”);exit(O);fwrite(&i,sizeof(structThing)J,fp);fclose(fp);voidmenu()intchoice;printfCAn0000OO8OOCOOOOOOO8OOOO8OOOO【超山管理系统】OO88OOOOOO8OOOOOOooooooooooW);printf(n系统菜单printf(,rt
3、CDprintf(ut②printf(ut③);新购物品入库】於);物品信息删除】於);物品信息修改】”);printf(Ht(4)【利用编号杏询】M);printf(nt@【利用种类查找】”);printf(ut@【物品信息浏览】”);printf(Ht⑦【应用程序退出】”);printf(Ht请输入您要选择的菜单......“);scanf(u%dH,&choice);switch(choice){case1:tianjia();break;case2:shanchu();b
4、reak;case3:xiugai();break;case4:chaxun();break;case5:chazhao();break;case6:liulan();break;case7:tuichu();break;default:printf(Httttt输入无效,请您重新输入……u);getch();system("cls");menu();})intvalidateID(intid){FILE*fp;structThingi;fp=fopen(uThing.date,r,Mr");if(fp==NULL){exit(O
5、);fread(&i,sizeof(stnictThing),l,fp);while(!feof(fp)){if(i.id==id){fclose(fp);return1;break;}fread(&i,sizeof(structThing),l,fp);}fclose(fp);return0;Ivoidtianjia(){structThingi;charchoice;FILE*fp;fp=fopen(uThing.date'V'ab");if(fp==NULL){printf("ttt系统错误,请您重试”);exit(O);Ilabl
6、D:printf(,r【请您输入要入库物品的信息…”);printf(,rtttt物品的编号:”);scnnf(”%<i”,&i.id);if(validateID(i.id)==1){printfC'tttt此编号已被使用,请您重新输入......”);gotolablD;)printf(utttt物品的名称:”);scan""%s",i.name);printf(Htttt物品的生产地:”);scanf(n%sM,i.produce);printf(utttt物品的数昴:”);scanf("
7、%d'&i.number);printf("tttt物品的单价:n);scanf(lf%f&i.price);printf(Htttt物品的种类:”);scanf("%sM,i.type);fwrite(&i,sizeof(structThing)J,fp);fclose(fp);printf(utttttt物品信息已入库成功!!!”);printf(H您想继续吗?(y/n)n);scanf("%c",&choice);if(choice==,Y'llchoice==y){tianjia();)else{
8、system("clsM);nienu();I}voidshanchu(){structThingi[1000];structThingtemp;in