资源预览内容
第1页 / 共11页
第2页 / 共11页
第3页 / 共11页
第4页 / 共11页
第5页 / 共11页
第6页 / 共11页
第7页 / 共11页
第8页 / 共11页
第9页 / 共11页
第10页 / 共11页
亲,该文档总共11页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
#include #include #include #include struct Infochar num20; char name20;int price; int amount;char menu() /*菜单选择函数*/ char n; /*n记录选择的菜单*/ system(cls); puts(tt 欢迎来到仓库货物管理系统 ); puts(tt*MENU*n); puts(tt* 1.录入货物信息 *n); puts(tt* 2.显示货物信息 *n); puts(tt* 3.查找货物信息 *n); puts(tt* 4.修改货物信息 *n); puts(tt* 5.删除货物信息 *n); puts(tt* 6.退出系统 *n); puts(tt*n); puts(*); printf(* 请选择你要输入数(1-6): *n); puts(*); while(1) n=getchar(); getchar(); if(n6) puts(*); printf(* 出错了!请再次输入(1-6): *n); puts(*); else break; return n; void append() /*货物信息输入函数*/ struct Info info; FILE * fp; char ch;if(fp=fopen(F:testfilemolde123.txt,wb) = NULL) printf(*n); printf(* 不能打开文件! *n); printf(*n); getch(); exit(1); do printf(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); ch=getchar(); getchar(); while(ch=Y|ch=y); fclose(fp); void printf1() printf(*n); printf(tt%-10st%-10st%-10st%-10sn,num,name,price,amountn);printf(*n); void printf2(struct Info info) printf(-n); printf(tt%-10st%-10st%-10dt%-10dn,info.num,info.name,info.price,info.amount ); printf(-n); void display() /*货物信息显示函数*/ struct Info info; FILE * fp; int m=0; if(fp=fopen(F:testfilemolde123.txt,rb)=NULL) printf(*); printf(* 不能打开文件! *); printf(*); 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(*n); printf(* 输入任何键继续 *); printf(*n); getch(); puts(nn); printf1(); fclose(fp); printf(*n); printf(* 总共有%d条记录在其中! *n,m); printf(*n); 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(*n); printf(* t 不能打开文件! *n); printf(*n); getch(); exit(1); do rewind(fp); printf(*n);printf(* 查询通过(1:编号 2:姓名): *n); printf(*n);while(1) scanf(%d,&flag); getchar(); if(flag2) printf(*n); printf(* 出错了!请再次输入1:编号2:姓名 *n); printf(*n); else break; if(flag=1) /*按编号进行查询*/ printf(*n); printf(* 请输入你要查询的编号: *n); printf(*n); gets(ch); total=0; /*符合条件的记录数*/ while(fread(&info,sizeof(info),1,fp)=1) if(strcmp(ch,info.num)=0) total+; if(total=1) printf1(); printf2(info);
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号