資源簡介
武漢理工大學軟件工程專業計算機基礎綜合實驗(c實驗),計費管理系統?;竟δ芗硬糠謹U展功能實現,經過驗收合格。

代碼片段和文件信息
#include
#include
#include
#include“model.h“
#include“global.h“
#include“tool.h“
int?saveBilling(const?Billing?*pBillingconst?char?*pPath)
{
FILE*?fp?=?NULL;
char?startTime[20]?=?{0};
char?endTime[20]?=?{0};
char?lastTime[20]?=?{0};
//打開文件
if((fp?=?fopen(pPath“a“))?==?NULL)
{
fp?=?fopen(pPath“w“);
if(fp?==?NULL)
{
return?FALSE;
}
}
timeToString(pBilling->tStartstartTime);
timeToString(pBilling->tEndendTime);
//將數據寫進文件
fprintf(fp“%s##%s##%s##%d##%.2f##%d\n“pBilling->aCardNamestartTime
endTimepBilling->nStatuspBilling->fAmountpBilling->nDel);
//關閉文件
fclose(fp);
return?TRUE;
}
int?getBillingCount(const?char*?pPath)
{
FILE*?fp?=?NULL;
int?nCount?=?0;
char?aBuf[BILLINGCHARNUM]?=?{0};
//打開文件
fp?=?fopen(pPath“r“);
if(fp?==?NULL)
{
return?FALSE;
}
//讀取文件
while(!feof(fp))
{
memset(aBuf0BILLINGCHARNUM);
if((fgets(aBufBILLINGCHARNUMfp))?!=?NULL)
{
if(strlen(aBuf)?>?0)
{
nCount++;
}
}
} //關閉文件
fclose(fp);
return?nCount;
}
Billing?praseBilling(char*?pBuf)
{
Billing?billing;
const?char?*delims?=??“##“;
char?flag[6][20]?=?{0};
int?index?=?0;
char?*buf?=?NULL;
char?*str?=?NULL;
buf?=?pBuf;
while((str?=?strtok(bufdelims))?!=?NULL)
{
strcpy(flag[index]str);
buf?=?NULL;
index++;
}
strcpy(billing.aCardNameflag[0]);
billing.tStart=stringToTime(flag[1]);
billing.tEnd=stringToTime(flag[2]);
billing.nStatus?=?atoi(flag[3]);
billing.fAmount=(float)atof(flag[4]);
billing.nDel=atoi(flag[5]);
return?billing;
}
int?readBilling(Billing*?pBillingconst?char*?pPath)
{
FILE*?fp?=?NULL;
int?i?=?0;
char?aBuf[BILLINGCHARNUM]?=?{0};
//打開文件
fp?=?fopen(pPath“r“);
if(fp?==?NULL)
{
return?FALSE;
}
//讀取文件
while(!feof(fp))
{
memset(aBuf0BILLINGCHARNUM);
if((fgets(aBufBILLINGCHARNUMfp))?!=?NULL)
{
if(strlen(aBuf)?>?0)
{
pBilling[i]?=?praseBilling(aBuf);
i++;
}
}
}
//關閉文件
fclose(fp);
return?TRUE;
}
int?updateBilling(const?Billing*?pBillingconst?char*?pPathint?nIndex)
{
FILE*?fp?=?NULL;
int?nLine?=?0;
char?aBuf[BILLINGCHARNUM]?=?{0};
long?lPosition?=?0;
char?startTime[TIMELENGTH]?=?{0};
char?endTime[TIMELENGTH]?=?{0};
fp?=?fopen(pPath“rb+“);
if(fp?==?NULL)
{
return?FALSE;
}
//遍歷文件找到該條記錄,進行更新
while(!feof(fp)?&&?nLine? {
if(fgets(aBufBILLINGCHARNUMfp)?!=?NULL)
{
lPosition?=?ftell(fp);
nLine++;
}
}
fseek(fplPosition0);
timeToString(pBilling->tStartstartTime);
timeToString(pBilling->tEndendTime);
//將數據寫進文件
fprintf(fp“\n%s##%s##%s##%d##%.2f##%d\n“pBilling->aCardNamestartTime
endTimepBilling->nStatuspBilling->fAmountpBilling->nDel);
fclose(fp);
return?TRUE;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4097??2018-04-07?00:53??AMS\AccountManagement\AccountManagement.vcxproj
?????文件???????2420??2018-04-07?00:53??AMS\AccountManagement\AccountManagement.vcxproj.filters
?????文件????????143??2018-02-26?14:33??AMS\AccountManagement\AccountManagement.vcxproj.user
?????文件???????2966??2018-04-07?13:09??AMS\AccountManagement\billing_file.c
?????文件????????320??2018-04-07?00:25??AMS\AccountManagement\billing_file.h
?????文件???????1803??2018-04-08?18:48??AMS\AccountManagement\billing_service.c
?????文件????????206??2018-04-07?00:21??AMS\AccountManagement\billing_service.h
?????文件???????3241??2018-04-07?13:16??AMS\AccountManagement\card_file.c
?????文件????????297??2018-04-02?16:45??AMS\AccountManagement\card_file.h
?????文件???????5075??2018-04-16?14:30??AMS\AccountManagement\card_service.c
?????文件????????446??2018-04-11?21:26??AMS\AccountManagement\card_service.h
?????文件????????830??2018-04-16?14:34??AMS\AccountManagement\data\billing.txt
?????文件????????633??2018-04-16?14:34??AMS\AccountManagement\data\card.txt
?????文件???????1064??2018-03-10?12:51??AMS\AccountManagement\Debug\AccountManagement.Build.CppClean.log
?????文件????????381??2018-04-16?14:30??AMS\AccountManagement\Debug\AccountManagement.exe.intermediate.manifest
?????文件?????????40??2018-04-16?14:31??AMS\AccountManagement\Debug\AccountManagement.lastbuildstate
?????文件???????2204??2018-04-16?14:31??AMS\AccountManagement\Debug\AccountManagement.log
?????文件????????713??2018-03-10?13:41??AMS\AccountManagement\Debug\AccountManagement.vcxprojResolveAssemblyReference.cache
?????文件??????????0??2018-03-10?12:51??AMS\AccountManagement\Debug\AccountManagement.write.1.tlog
?????文件??????14245??2018-04-07?13:10??AMS\AccountManagement\Debug\billing_file.obj
?????文件???????7806??2018-04-08?18:49??AMS\AccountManagement\Debug\billing_service.obj
?????文件??????14543??2018-04-11?21:28??AMS\AccountManagement\Debug\card_file.obj
?????文件??????16084??2018-04-16?14:30??AMS\AccountManagement\Debug\card_service.obj
?????文件???????4654??2018-04-16?14:30??AMS\AccountManagement\Debug\cl.command.1.tlog
?????文件??????11940??2018-04-16?14:30??AMS\AccountManagement\Debug\CL.read.1.tlog
?????文件??????12240??2018-04-16?14:30??AMS\AccountManagement\Debug\CL.write.1.tlog
?????文件???????2164??2018-04-16?14:31??AMS\AccountManagement\Debug\li
?????文件???????3834??2018-04-16?14:31??AMS\AccountManagement\Debug\li
?????文件???????1228??2018-04-16?14:31??AMS\AccountManagement\Debug\li
?????文件???????7443??2018-04-11?21:28??AMS\AccountManagement\Debug\main.obj
............此處省略36個文件信息
- 上一篇:MP和OMP算法
- 下一篇:STM32無刷直流電機PWM控制
評論
共有 條評論