删除货物信息C语言程序,C语言程序仓库管理系统

《C语言程序仓库管理系统》由会员分享,可在线阅读,更多相关《C语言程序仓库管理系统(12页珍藏版)》请在人人文库网上搜索。

1、include #include #include #include struct Infochar num20; char name20; int price; int amount;1*1*char menu()char n;/* 菜单选择函数 */*n 记录选择的菜单 */system(cls);puts(tt 欢迎来到仓库货物管理系统 );puts(tt*MENU*puts(tt* puts(tt* puts(tt* puts(tt* puts(tt* puts(tt*1.录入货物信息*n);2.显示货物信息*n);3.查找货物信息*n);4.修改货物信息*n);5.删除货物信息*n)。

2、;6.退出系统*n);puts(tt*n););puts( printf(* 请选择你要输入数 (1-6): *n););puts(while(1)n=getchar(); getchar();if(n6) );puts( printf(* 出错了!请再次输入 (1-6): *n);puts(1*);elsebreak; return n;/* 货物信息输入函数 */void append()struct Info info; FILE * fp; char ch;if(fp=fopen(F:testfilemolde123.txt,wb) = NULL)printf(H*n);printf(。

3、* 不能打开文件 ! *n);printf(H*n);getch();exit(1);doprintf(tnum:); gets(info.num);printf(tname:);gets(info.name);printf(tprice:);scanf(%d,&info.price);printf(tamount:); scanf(%d,&info.amount); getchar();fwrite(&info,sizeof(info),1,fp);printf(*n);printf(* 还需要输入吗 ?(Y/N):*n);printf(*n);printf(printf(*n);ch=ge。

4、tchar();getchar();while(ch=Y|ch=y); fclose(fp);void printf1()H*n);printf(tt%-10st%-10st%-10st%-10sn,num,name,price,amountn);*void printf2(struct Info info) printf(n);printf(tt%-10st%-10st%-10dt%-10dn,info.num,info.name,info.price,info.amount );printf(n);/* 货物信息显示函数 */printf(*);printf(* 不能打开文件 ! *);p。

5、rintf(*);getch();exit(1);while(fread(&info,sizeof(info),1,fp)=1)m+;if(m=1)printf1();printf2(info);if(m!=0)&(m%10=0)printf();printf(* 输入任何键继续 *);printf();void display()struct Info info;FILE * fp;int m=0;if(fp=fopen(F:testfilemolde123.txt,rb)=NULL) getch();puts(nn); printf1();fclose(fp);*n,m);printf(*。

6、n); printf(* 总共有 %d 条记录在其中 !*n);printf(getch();void search() /* 货物信息查询函数 */struct Info info;FILE * fp;int flag;/* flag 为 1 按编号查询 ,flag 为 2 按姓名查询 */int total=0;/* 记录符合条件的记录的个数 */char ch10; char f;if(fp=fopen(F:testfilemolde123.txt,rb) = NULL) printf(H*n);printf(* t 不能打开文件*n);printf();H*getch();exit(1。

7、);dorewind(fp);printf(*printf(*查询通过 (1:编号 2:姓名 ):*n);printf();while(1)scanf(%d,&flag);getchar();if(flag2)printf(*n);printf(* 出错了!请再次输入 1:编号2 :姓名 *n);printf(*n);elsebreak;if(flag=1) /* 按编号进行查询 */printf(*n);printf(* 请输入你要查询的编号:*n);printf();gets(ch);total=0;/* 符合条件的记录数 */while(fread(&info,sizeof(info),。

8、1,fp)=1) if(strcmp(ch,info.num)=0) total+; if(total=1) printf1(); printf2(info);else/* 按姓名进行查询 */printf(*n);printf(* 请输入你要查询的姓名:*n);printf();gets(ch);total=0;while(fread(&info,sizeof(info),1,fp)=1) if(strcmp(ch,info.name)=0) total+;if(total=1)printf1();printf2(info);printf( *printf(*总共有 %d 记录在其中 !*n。

9、,total);printf( *printf( *printf(printf(* 还需要查询吗 ?(Y/N):*n);printf(H*f=getchar();getchar();while(f=Y|f=y); fclose(fp);void modify() /* 货物信息修改函数 */ struct Info info;FILE * fp1,* fp2; int flag; char ch10; char f;NULL)do if(fp1=fopen(F:testfilemolde123.txt,rb) = printf( *printf( *不能打开文件 !*n);printf( * 。

10、getch();exit(1);= NULL)if(fp2=fopen(F:testfilemolde456.txt,wb)printf( *printf( *不能打开文件 !*n);getch();exit(1);printf(*n);printf(*请输入你要修改的货物编号:*n);printf(*n);gets(ch);flag=0;while(fread(&info,sizeof(info),1,fp1)=1)if(strcmp(ch,info.num)=0)printf1();printf2(info);printf(*n);printf(* 请输入新的信息:*n);printf(H。

11、*n);printf(tnum:);gets(info.num);printf(tname:);gets(info.name);printf(tprice:);scanf(%d,&info.price);printf(tamount:); scanf(%d,&info.amount); getchar();flag=1; fwrite(&info,sizeof(info),1,fp2);fclose(fp1); fclose(fp2);if(flag=1)*n);printf( *n); printf(* 修改成功 !printf( *n);remove(F:testfilemolde123.。

12、txt);rename(F:testfilemolde456.txt,F:testfilemolde123.txt); elseprintf(*n);printf(* 不能找到这个记录*n);printf(H*n);printf(*printf(* 还修改其他吗 ?(Y/N):*n);printf(H*n);H*f=getchar();getchar();while(f=y|f=Y); void Delete()struct Info info;FILE * fp1,* fp2; int flag;char ch10; char f;/* 货物信息删除函数 */do if(fp1=fopen(。

13、F:testfilemolde123.txt,rb) = NULL)*n);printf(printf(* t 不能打开文件*n);printf(H*n);getch(); exit(1);if(fp2=fopen(F:testfilemolde456.txt,wb) = NULL)printf(*n);printf(* t 不能打开文件*n);printf(H*n);getch();exit(1);printf(H*n);printf(* 请输入你需要删除货物的编号*n);printf();gets(ch);flag=0;while(fread(&info,sizeof(info),1,fp。

14、1)=1) if(strcmp(ch,info.num)=0)printf1(); printf2(info); flag=1;break;elsefwrite(&info,sizeof(info),1,fp2);fclose(fp1);fclose(fp2);if(flag=1)printf(H*n);printf(* 删除成功 !*n);printf(H*n);remove(F:testfilemolde123.txt);rename(F:testfilemolde456.txt,F:testfilemolde123.txt);else*n);printf( * printf(* 不能找到。

15、这个记录 ! printf( * *n);printf( * printf(* 还删除其他吗 ?(Y/N): printf( *f=getchar(); getchar();while(f=y|f=Y);void main()/* 主函数 */while(1)int a;char f;char ch10;char num20=12345;printf(please input the secret :n);scanf(%s,ch);if(strcmp(num,ch)=0)a=1; if(a=1) printf(nplease enter in the telproject !n);f=getchar(); getchar();break;elseprintf(n the secret is error); printf(please input the right secret);while(1) switch(menu()case1:append();break; case2:display();break; case3:search();break; case4:modify();break; case5:Delete();break; case6:exit(0);break。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值