资源描述:
《超市管理系统作业》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、/*程序名:supermarket.c*//*作者:ZhangDaPan*//*编程日期:2011-06-10*/#include#include#include#include#include#include//#defineNULL0/*****函数说明*******/voidlogin();voidfront_user();voidback_user();voidgoods();voidsale();vo
2、idgoodswarm();voidmember();/****结构体定义********/structmember{intnumber;charname[20];floatsale_sum;charlever;structmember*next;};structgoods{intgoodsnum;chargoodsname[30];floatprice;intamount;intline;structgoods*next;};structuser{charusername[10];charpassword[10];c
3、hartype;structuser*next;};/*******全局变量定义*******/structgoods*goods_head=NULL;structmember*member_head=NULL;structuser*user_head=NULL;/*******************************************主函数*************************************/main(){//导入user数据:从文件中导入事先写好的数据;structuser*us
4、er_p;FILE*user_fp;structgoods*goods_p;FILE*goods_fp;user_fp=fopen("d:\user.txt","r");user_p=(structuser*)malloc(sizeof(structuser));user_head=user_p;fscanf(user_fp,"%s",user_p->username);//printf("%s",user_p->username);fscanf(user_fp,"%s",user_p->password);//
5、printf("%s",user_p->password);fscanf(user_fp,"%c",&(user_p->type));//printf("%c",user_p->type);user_p->next=NULL;while(!feof(user_fp))//注释:feof(fp)指的是未遇到文件结束为0,!feof(fp)为1,即为真,则执行while循环{user_p->next=(structuser*)malloc(sizeof(structuser));//为user_p->next在
6、内存动态存储空间分配大小为sizeof(structuser)字节的连续区域user_p=user_p->next;fscanf(user_fp,"%s",user_p->username);//printf("%s",user_p->username);fscanf(user_fp,"%s",user_p->password);//printf("%s",user_p->password);fscanf(user_fp,"%c",&(user_p->type));//printf("%c",user_
7、p->type);user_p->next=NULL;}//user_p=user_head;//调试时用;//while(user_p)//{//printf("%s,",user_p->username);//printf("%s,",user_p->password);//printf("%c,",user_p->type);//user_p=user_p->next;////}fclose(user_fp);//getchar();/************************导入goods数据******
8、*************************************/goods_fp=fopen("d:\goods.txt","r");goods_p=(structgoods*)malloc(sizeof(structgoods));goods_head=goods_p;fscanf(goods_fp,"%d",&(