超市管理系统源代码.doc

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
#includestdio.h #includestring.h struct goodinfo { char no[15]; char name[15]; float price; }good[1000]; int flag;/*全局变量,在search函数中用于标记查询到的商品的序号,传递 到edit()函数中*/ int flag2=0;/*全局变量,在delete()中当flag2=1时终止search()中查询商品的循环*/ void add() { struct goodinfo good1;char a[3]=00;int flag2=0; int m,j=0; FILE *fp; fp=fopen(goodinfo.c,ab+); if(fp==NULL){printf(\nerror on open the file!!!\n);getchar(); exit(0);} while(1) {printf(please input goods information to add it!!input \00\ to give up adding!!\n); printf(no:); scanf(%s,good1.no); if(strcmp(good1.no,a)==0) break; for(j=0;j1000;j++) { fread(good[j],sizeof(struct goodinfo),1,fp); if(strcmp(good[j].no,good1.no)==0) { flag2=1; printf(the goods already exists!!!\n);break;} } if(flag2==1)break; printf(name:); scanf(%s,good1.name); printf(price:); scanf(%f,good1.price); m=fwrite(good1,sizeof(struct goodinfo),1,fp); if(m!=1)printf(error adding!!!\n); else{ printf(success in adding the following information!!); printf(\nno: %s, name: %s, price: %.2f RMB\n,good1.no,good1.name,good1.price); } rewind(fp); } fclose(fp); } void search() { int i=0,j;char no1[15], no2[3]=00; FILE *fp; fp=fopen(goodinfo.c,ab+); if(fp==NULL){printf(error on open the file!!!);getchar(); exit(0);} while(1) { printf(please input the no. you want to search!!!input \00\to quit!!\n); scanf(%s,no1); if(strcmp(no1,no2)==0) break; for(i=0;i1000;i++) fread(good[i],sizeof(struct goodinfo),1,fp); for(j=0;j1000;j++) { if(strcmp(good[j].no,no1)==0) break;} if(j==1000) printf(can not find the goods!!!\n); else{ printf(find it!! the goodsinformation is:%d\n ,flag); printf(\nno:%s,name: %s, price:%.2f\n\n,good[j].no,good[j].name,good[j].price); flag=j; /*将查询到的商品在数组good中的序号传递出去*/ if(flag2==1) break; /*在delete函数中用于终止while(1)的循环*/ } } fclose(fp); } int delete() { int i;char ch ; FILE *fp; flag2=1;/*flag2置1,在调用search函数时终止其循环*/ search(); getchar();/*接受回车符号,防止干扰选项*/ printf( Are you sure to delete it? ); printf(\Y\or\y\-YES . \ N\or \

文档评论(0)

a13355589 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档