资源描述:
《C语言订餐系统.doc》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、#include#include#includestructconsumer{charstu_name[30],stu_Place[20];//定义客户姓名,地点charstu_time[20],stu_madetime[20],stu_memu[20];//定义用餐时间,订单生成时间,菜单intstu_num;//用餐人数}order;voidreserve()//订餐{inti;printf("请输入客户姓名:");scanf("%s",&order.stu_name);s
2、trcat(order.stu_name,".txt");//将后一个字符串加到前一个FILE*fp1=fopen(order.stu_name,"w");//打开文档if(fp1==NULL)//若文件打开失败{printf("文件打开失败");exit(0);}FILE*fp2=fopen("d:\总表.txt","a+");//打开文档if(fp2==NULL)//若文件打开失败{printf("文件打开失败");exit(0);}fprintf(fp1,"客户姓名:%s",order.stu_name);fpri
3、ntf(fp2,"客户姓名:%s",order.stu_name);printf("请输入用餐人数:");scanf("%d",&order.stu_num);fprintf(fp1,"用餐人数:%d",order.stu_num);fprintf(fp2,"用餐人数:%d",order.stu_num);printf("请输入用餐时间:");scanf("%s",&order.stu_time);fprintf(fp1,"用餐时间:%s",order.stu_time);fprintf(fp2,"用餐时间:%s"
4、,order.stu_time);printf("请输入包间或餐桌号:");scanf("%s",&order.stu_Place);fprintf(fp1,"包间号\餐桌号:%s",order.stu_Place);fprintf(fp2,"包间号\餐桌号:%s",order.stu_Place);printf("请点菜:");fprintf(fp1,"所点的菜:");fprintf(fp2,"所点的菜:");for(i=1;;i++){scanf("%s",&order.stu_memu);fprintf(fp1,"%
5、s",&order.stu_memu);fprintf(fp2,"%s",&order.stu_memu);if(getchar()=='')break;}printf("请输入订单生成时间:");scanf("%s",&order.stu_madetime);fprintf(fp1,"订单生成时间:%s",order.stu_madetime);fprintf(fp2,"订单生成时间:%s",order.stu_madetime);}voidfind()//查询{charline1[150];charline2[150]
6、;charline3[150];charline4[150];charline5[150];charline6[150];printf("请输入客户名:");scanf("%s",&order.stu_name);strcat(order.stu_name,".txt");FILE*fp;if((fp=fopen(order.stu_name,"r"))==NULL)//打开文档;{printf("客户不存在");exit(0);}fgets(line1,150,fp);printf("%s",line1);fgets(line2
7、,150,fp);printf("%s",line2);fgets(line3,150,fp);printf("%s",line3);fgets(line4,150,fp);printf("%s",line4);fgets(line5,150,fp);printf("%s",line5);fgets(line6,150,fp);printf("%s",line6);//读取文档和显示输出;fclose(fp);getchar();}voiddeletes()//删除{charline1[150];charline2
8、[150];charline3[150];charline4[150];charline5[150];charline6[150];charreason[150];charchoice;printf("请输入客户姓名: