資源簡介
用c語言編寫 自己寫的運行絕對沒問題,內(nèi)含有需求文檔
代碼片段和文件信息
/*
作者:梁運杰
日期:2013-08-22
功能:購物系統(tǒng)業(yè)務(wù)模塊實現(xiàn)
*/
#include?“business.h“
#include?“view.h“
/*
*功能:清除輸入緩存函數(shù)
*參數(shù):無
*返回值:無
*/
void?fflush_in()
{
char?c?=?‘\0‘;
c?=?getchar();
while(c?!=?‘\n‘)
c?=?getchar();
}
/*
*功能:獲取?0?~?n(不包括?n)?之間的隨機(jī)數(shù)
*參數(shù):n_任意正整數(shù)?cause_隨機(jī)數(shù)因子
*返回值:0?~?n?之間的隨機(jī)數(shù)
*/
int?usr_rand(int?nint?cause)
{
srand((unsigned)time(NULL)?+?cause);
return?rand()?%?n;
}
/*
*功能:用戶選擇函數(shù)
*參數(shù):無
*返回值:無
*/
//創(chuàng)建用戶新節(jié)點
USR?*usr_create()
{
return?malloc(sizeof(USR));
}
//初始化用戶頭節(jié)點
int?init_usr_head(USR?*usr_head)
{
if(NULL?==?usr_head)
return?1;
usr_head->prev?=?usr_head;
usr_head->next?=?usr_head;
return?0;
}
//創(chuàng)建商品信息新節(jié)點
COMMODITY?*com_create()
{
return?malloc(sizeof(COMMODITY));
}
//初始化商品信息頭節(jié)點
int?init_com_head(COMMODITY?*com_head)
{
if(NULL?==?com_head)
return?1;
com_head->prev?=?com_head;
com_head->next?=?com_head;
return?0;
}
//創(chuàng)建購物車信息新節(jié)點
CART?*cart_create()
{
return?malloc(sizeof(CART));
}
//初始化購物車信息頭節(jié)點
int?init_cart_head(CART?*cart_head)
{
if(NULL?==?cart_head)
return?1;
cart_head->prev?=?cart_head;
cart_head->next?=?cart_head;
return?0;
}
//創(chuàng)建購買信息新節(jié)點
BUY?*buy_create()
{
return?malloc(sizeof(BUY));
}
//初始化購買信息頭節(jié)點
int?init_buy_head(BUY?*buy_head)
{
if(NULL?==?buy_head)
return?1;
buy_head->prev?=?buy_head;
buy_head->next?=?buy_head;
return?0;
}
/*
*功能:從文件usrdb中讀取用戶信息初始化鏈表
*參數(shù):head_頭節(jié)點
*返回值:0--成功?1--參數(shù)問題?2--文件操作失敗?3--空間分配失敗
*/
int?init_usr_link(USR?*usr_head)
{
FILE?*fp=NULL;
USR?*usr=NULL;
if(NULL==usr_head)
return?1;
fp=fopen(“usrdb““r“);
if(NULL==fp){
fp?=?fopen(“usrdb““w“);
if(NULL?==?fp)
return?2;
}
else{
usr=usr_create(); //新建節(jié)點
if(NULL==usr)
return?3;
while(fread(usrsizeof(USR)1fp)!=0){
insert_usr_end(usr_headusr);
usr=usr_create();
if(NULL==usr)
return?3;
}
}
free(usr);
fclose(fp);
return?0;
}
/*
*功能:從文件cartdb中讀取用戶信息初始化鏈表
*參數(shù):cart_head_頭節(jié)點
*返回值:0--成功?1--參數(shù)問題?2--文件操作失敗?3--空間分配失敗
*/
int?init_cart_link(CART?*cart_head)
{
FILE?*fp=NULL;
CART?*cart=NULL;
if(NULL==cart_head)
return?1;
fp=fopen(“cartdb““r“);
if(NULL==fp){
fp?=?fopen(“cartdb““w“);
if(NULL?==?fp)
return?2;
}
else{
cart=cart_create();
if(NULL==cart)
return?3;
while(fread(cartsizeof(CART)1fp)!=0){
insert_cart_end(cart_headcart);
cart=cart_create();
if(NULL==cart)
return?3;
}
}
free(cart);
fclose(fp);
return?0;
}
/*
*功能:從文件comdb中讀取商品信息初始化鏈表
*參數(shù):head_頭節(jié)點
*返回值:0--成功?1--參數(shù)問題?2--文件操作失敗?3--空間分配失敗
*/
int?init_com_link(COMMODITY?*com_head)
{
FILE?*fp=NULL;
COMMODITY?*com=NULL;
if(NULL==com_head)
return?1;
fp=fopen(“comdb““r“);
if(NULL==fp){
fp?=?fopen(“comdb““w“);
if(NULL?==?fp)
return?2;
}
else{
com=com_create();
if(NULL==com)
return?3;
while(fread(comsizeof(COMMODITY)1fp)!=0){
insert_com_end(com_headcom);
com=com_create();
if(NULL==com)
return?3;
}
}
free(com);
fclose(fp);
return?0;
}
/*
*功能:從文件buydb中讀取購買信息初始化鏈表
*參數(shù):head_頭節(jié)點
*返回值:0--成功?1--參數(shù)問題?2--文件操作失敗?3--空間分配失敗
*/
int?init_buy_link(BUY
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????49148??2013-08-22?16:30??網(wǎng)上購物系統(tǒng)\shop\a.out
?????文件??????34421??2013-08-27?08:52??網(wǎng)上購物系統(tǒng)\shop\business.c
?????文件??????32688??2013-08-24?22:31??網(wǎng)上購物系統(tǒng)\shop\business.c~
?????文件???????5138??2013-08-26?16:54??網(wǎng)上購物系統(tǒng)\shop\business.h
?????文件??????21436??2013-08-27?08:52??網(wǎng)上購物系統(tǒng)\shop\business.o
?????文件???????1100??2013-08-27?10:32??網(wǎng)上購物系統(tǒng)\shop\buydb
?????文件?????????92??2013-08-27?10:32??網(wǎng)上購物系統(tǒng)\shop\cartdb
?????文件????????512??2013-08-27?10:32??網(wǎng)上購物系統(tǒng)\shop\comdb
?????文件??????11405??2013-08-26?17:10??網(wǎng)上購物系統(tǒng)\shop\control.c
?????文件???????1480??2013-08-25?00:13??網(wǎng)上購物系統(tǒng)\shop\control.h
?????文件???????8936??2013-08-27?08:41??網(wǎng)上購物系統(tǒng)\shop\control.o
?????文件??????30934??2013-08-27?08:52??網(wǎng)上購物系統(tǒng)\shop\main
?????文件????????140??2013-08-16?15:23??網(wǎng)上購物系統(tǒng)\shop\main.c
?????文件????????764??2013-08-19?09:20??網(wǎng)上購物系統(tǒng)\shop\main.o
?????文件????????280??2013-08-16?15:31??網(wǎng)上購物系統(tǒng)\shop\makefile
?????文件????????286??2013-08-22?15:14??網(wǎng)上購物系統(tǒng)\shop\std.h
?????文件???????1490??2013-08-25?00:18??網(wǎng)上購物系統(tǒng)\shop\struct.h
?????文件????????576??2013-08-27?10:32??網(wǎng)上購物系統(tǒng)\shop\usrdb
?????文件???????4584??2013-08-26?16:55??網(wǎng)上購物系統(tǒng)\shop\view.c
?????文件????????721??2013-08-22?10:39??網(wǎng)上購物系統(tǒng)\shop\view.h
?????文件???????3444??2013-08-26?17:00??網(wǎng)上購物系統(tǒng)\shop\view.o
?????文件??????52736??2013-09-25?16:54??網(wǎng)上購物系統(tǒng)\電子商務(wù)系統(tǒng)說明書.doc
?????目錄??????????0??2013-09-23?17:15??網(wǎng)上購物系統(tǒng)\shop
?????目錄??????????0??2013-09-25?16:55??網(wǎng)上購物系統(tǒng)
-----------?---------??----------?-----??----
???????????????262311????????????????????24
- 上一篇:小甲魚C語言課件 源代碼
- 下一篇:MFC數(shù)字鐘(基于VC6.0)
評論
共有 條評論