欢迎来到天天文库
浏览记录
ID:40888009
大小:17.78 KB
页数:8页
时间:2019-08-09
《超市商品管理系统代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、超市商品管理系统中文提示ByAzxXINER#include#include#include#include//-------------------------------------------------------------//Maxcountofgood,def100temporary//-------------------------------------------------------------#defineMAX10
2、0intcurrent_cnt=0;//-------------------------------------------------------------//GoodInformationDefinition//-------------------------------------------------------------typedefstructGoodInfo{chargood_id[30];chargood_name[30];chargood_price[10];chargood_discount[
3、10];intgood_amount;intgood_remain;}GoodInfo;GoodInfo*Goods[MAX];//-------------------------------------------------------------//freegoodinfomemory//-------------------------------------------------------------voidfreeGoodInfo(){inti=0;for(i=0;i4、[i]);Goods[i]=NULL;}//-------------------------------------------------------------//readagoodinfofromfile//-------------------------------------------------------------GoodInfo*readGoodInfo(FILE*fp){GoodInfo*pGoodInfo=(GoodInfo*)malloc(sizeof(GoodInfo));fscanf(fp5、,"%s",&pGoodInfo->good_id);fscanf(fp,"t%s",&pGoodInfo->good_name);fscanf(fp,"t%s",&pGoodInfo->good_price);fscanf(fp,"t%s",&pGoodInfo->good_discount);fscanf(fp,"t%d",&pGoodInfo->good_amount);fscanf(fp,"t%d",&pGoodInfo->good_remain);returnpGoodInfo;}//-------6、------------------------------------------------------//checkwhetherthefileexistsornot//-------------------------------------------------------------intcheck_nullfile(){FILE*fp=fopen("F:\课程\C语言程序设计\综合实验2超市商品管理系统\goodinfo.txt","r");//filenotexistif(!fp){printf(7、"商品信息初始化文件不存在!请您放到E盘根目录!");fp=fopen("F:\课程\C语言程序设计\综合实验2超市商品管理系统\goodinfo.txt","w");fclose(fp);}//filealreadyexistelse{inttemp;//resfortrytoreadfileiffilenullfeof()can'tjargeiffileisnullintres=fscanf(fp,"%d",&temp);fclose(fp);if(res<=0)return-1;elsereturn18、;}}//-------------------------------------------------------------//initialize//-------------------------------------------------------------voidinfo_in
4、[i]);Goods[i]=NULL;}//-------------------------------------------------------------//readagoodinfofromfile//-------------------------------------------------------------GoodInfo*readGoodInfo(FILE*fp){GoodInfo*pGoodInfo=(GoodInfo*)malloc(sizeof(GoodInfo));fscanf(fp
5、,"%s",&pGoodInfo->good_id);fscanf(fp,"t%s",&pGoodInfo->good_name);fscanf(fp,"t%s",&pGoodInfo->good_price);fscanf(fp,"t%s",&pGoodInfo->good_discount);fscanf(fp,"t%d",&pGoodInfo->good_amount);fscanf(fp,"t%d",&pGoodInfo->good_remain);returnpGoodInfo;}//-------
6、------------------------------------------------------//checkwhetherthefileexistsornot//-------------------------------------------------------------intcheck_nullfile(){FILE*fp=fopen("F:\课程\C语言程序设计\综合实验2超市商品管理系统\goodinfo.txt","r");//filenotexistif(!fp){printf(
7、"商品信息初始化文件不存在!请您放到E盘根目录!");fp=fopen("F:\课程\C语言程序设计\综合实验2超市商品管理系统\goodinfo.txt","w");fclose(fp);}//filealreadyexistelse{inttemp;//resfortrytoreadfileiffilenullfeof()can'tjargeiffileisnullintres=fscanf(fp,"%d",&temp);fclose(fp);if(res<=0)return-1;elsereturn1
8、;}}//-------------------------------------------------------------//initialize//-------------------------------------------------------------voidinfo_in
此文档下载收益归作者所有