1、商品信息管理系统C语言课程设计#include#include#include#include#define N 100struct commodity char option20; char name20; char price10; char production_date8; char stale_date8; char finished_goods20; char saleroom20;void print_1();void create();void edit();void print_2(); /*invoked of edit*/void edit_add(); /*invoke
2、d of edit*/void edit_modify(); /*invoked of edit*/void edit_delete(); /*invoked of edit*/void delete_option(); /*invoked of 2delete*/void delete_name(); /*invoked of 2delete*/void show();void search();void search_option(); /*invoked of search*/void search_name(); /*invoked of search*/main() char cho
3、ose=0,yes_no=0; do print_1(); choose=getch(); switch(choose) case1:create();break; /*create information of commodity*/ case2:edit();break; /*edit information of commodity*/ case3:show();break; /*show information of commodity*/ case4:search();break; /*search information of commodity*/ case0:exit(0);
4、default:printf(n %c is illegality option!n,choose); printf(n Do you want to continue(y/n)?); do yes_no=getche(); while(yes_no!=Y&yes_no!=y&yes_no!=N&yes_no!=n); while(yes_no=Y|yes_no=y);void print_1() /*show limiting surface of menu*/ clrscr(); /*clearn screen of function*/ printf(*n); printf(* Mana
5、gesystem of Commodity Information *n); printf(*n); printf( |*|n); printf( | Please input option number |n); printf( |n); printf( | 1-Create commodity information |n); printf( | 2-Edit commodity information |n); printf( | 3-Show commodity information |n); printf( | 4-Search commodity information |n);
6、 printf( | 0-Exit system |n); printf( |*|n);void create() /*create information of commodity for function*/ int i=0,j,num; struct commodity temp=0; FILE *fp=NULL; fp=fopen(D:commodity.txt,w); if(fp=NULL) printf(n File of information of commodity opening failed.n); return ; clrscr(); /*clearn screen o
7、f function*/ printf(Please input want to input the number of goods!); scanf(%d,&num); for(j=1;num=j;j+) printf(nPlease input %d record:n,j); printf( number:); do gets(temp.option); while(strcmp(temp.option,)=0); printf( name:); gets(temp.name); printf( price:); gets(temp.price); printf( production:)
8、; gets(temp.production_date); printf( stale_date:); gets(temp.stale_date); printf( finished_goods:); gets(temp.finished_goods); printf( saleroom:); gets(temp.saleroom); fprintf(fp,%s %s %s %s %s %s %sn,temp.option,temp.name,temp.price, temp.production_date,temp.stale_date,temp.finished_goods,temp.st
9、ale_date); i+; fclose(fp);void edit() /*edit information of commodity for function*/ char choose=0,yes_no=0,pass20=0,old20=0,w; int i=0,j,m=0; FILE *fp_code; fp_code=fopen(D:code.txt,r); if(fp_code=NULL) printf(n File of code opening failed.n); return ; fscanf(fp_code,%s,old); fclose(fp_code); for(j
10、=0;j=3) exit(1); do print_2(); printf( ); choose=getch(); switch(choose) case1:edit_add();break; /*add new information of commodity*/ case2:edit_modify();break; /*modify information of commodity*/ case3:edit_delete();break; /*delete information of commodity*/ case0:exit(0); default:printf(n %c is il
11、legality option!n,choose); printf(n Do you want to continue(y/n)?); do yes_no=getche(); while(yes_no!=Y&yes_no!=y&yes_no!=N&yes_no!=n); while(yes_no=Y|yes_no=y);void print_2() /*show limiting surface of menu*/ clrscr(); /*clearn screen of function*/ printf(*n); printf(* Managesystem of Commodity Inf
12、ormation *n); printf(*n); printf( |*|n); printf( | Please input option number |n); printf( |n); printf( | 1-Add commodity information |n); printf( | 2-Modify commodity information |n); printf( | 3-Delete commodity information |n); printf( | 0-Exit system |n); printf( |*|n);void edit_add() /*add new
13、information of commodity*/ char c=0; int n=0; struct commodity temp=0,recordN=0,*p=NULL; FILE *fp=NULL; fp=fopen(D:commodity.txt,r); if(fp=NULL) printf(n File opening failed.n); return; p=record; while(feof(fp)=0) fscanf(fp,%s%s%s%s%s%s%s,p-option,p-name,p-price,p-production_date,p-stale_date, p-fin
14、ished_goods,p-saleroom); p+; n+; fclose(fp); do printf(n Please input new option:); do gets(temp.option); while(strcmp(temp.option, )=0); printf( Please input new name:); gets(temp.name); printf( Please input new price:); gets(temp.price); printf( Please input new production:); gets(temp.production_
15、date); printf( Please input new stale_date:); gets(temp.stale_date); printf( Please input new finished_goods:); gets(temp.finished_goods); printf( Please input new saleroom:); gets(temp.saleroom); for(p=record;poption)=0) printf(n The option is repeat,if you want to input again(y/n)?); do c=getche()
16、; while(c!=Y&c!=y&c!=N&c!=n); putchar(n); break; if(p=record+n) *p=temp; break; while(c=y|c=Y); fp=fopen(D:commodity.txt,w); if(fp=NULL) printf(n File opening failed.n); return; for(p=record;poption,p-name,p-price,p-production_date,p-stale_date, p-finished_goods,p-saleroom); fclose(fp);void edit_mod
17、ify() /*modify information of commodity*/ char c=0; int n=0; struct commodity *find=NULL,temp=0,record100=0,*p=NULL; FILE *fp=NULL; fp=fopen(D:commodity.txt,r); if(fp=NULL) printf(n File opening failed.n); return; p=record; while(!feof(fp) fscanf(fp,%s%s%s%s%s%s%s,p-option,p-name,p-price,p-productio
18、n_date,p-stale_date, p-finished_goods,p-saleroom); p+; n+; fclose(fp); if(n=0) printf(n No record in this file.n); return; printf(n Please input you want to commodityoption:); gets(temp.option); for(p=record;poption)=0) find=p; break; if(p=record+n) printf(n No this commodity.n); return; do printf(n
19、 Please input right option.:); do gets(temp.option); while(strcmp(temp.option, )=0); printf( Please input right name:); gets(temp.name); printf( Please input right price:); gets(temp.price); printf( Please input right production:); gets(temp.production_date); printf( Please input right stale_date:);
20、 gets(temp.stale_date); printf( Please input right finished_goods:); gets(temp.finished_goods); printf( Please input right saleroom:); gets(temp.saleroom); for(p=record;poption)=0&(p!=find) printf(n The option is repeat,do you want to continue?(y/n); do c=getche(); while(c!=Y&c!=y&c!=N&c!=n); putcha
21、r(n); break; if(p=record+n) *find=temp; break; while(c=y)|(c=Y); fp=fopen(D:commodity.txt,w); if(fp=NULL) printf(n File opening is failed.n); return; for(p=record;poption,p-name,p-price,p-production_date,p-stale_date, p-finished_goods,p-saleroom); fclose(fp);void edit_delete() /*delete information o
22、f commodity*/ char c=0; printf(n According to the option(o) to delete, delete or by the name(n)?); c=getche(); if(c=o|c=O) delete_option(); else if(c=n|c=N) delete_name(); else printf(n This char is illegal.n);void delete_option() /*delete information of commodity by option*/ char tempoption10= ; in
23、t n=0; struct commodity recordN=0,*p=NULL,*k=NULL; FILE *fp=NULL; fp=fopen(D:commodity.txt,r); if(fp=NULL) printf(n File opening is failed.n); return; p=record; while(!feof(fp) fscanf(fp,%s%s%s%s%s%s%s,p-option,p-name,p-price,p-production_date,p-stale_date, p-finished_goods,p-saleroom); p+; n+; fclose(fp); printf(n Please input you want to delete the option:); gets(tempoption); for(k=record;koption)=0) break; if(krecord+n) for(p=k;pk+n-1;p+) *p=*(p+1); else printf(n No such commodify.n); fp=fopen(D:commodi
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1