|
|
我要如何把我的customer.txt中的balance修改成total的数字呢?
以下是我的coding
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
struct BIRTH
{
int day,month,year;
};
struct DATE
{
int transday,transmonth,transyear;
};
struct student
{
char acc_num[9];
char name[51];
char address[100];
struct BIRTH birth;
double balance;
struct DATE date;
}detail;
void charges()
{
char accnum[9];
double fees,workbook,total;
FILE *cust;
printf("You choose\n"
"FEES PAYMENT COUNTER\n");
printf("Please enter your account number : ");
scanf("%s",&accnum);
if(!(cust = fopen("customer.txt","r")))
{
printf("Cannot open the file\n");
exit(-1);
}
while((fscanf(cust,"%[^\|]|%[^\|]|%[^\|]|%d %d %d|%lf|%d %d %d\n", detail.acc_num, detail.name, detail.address, &detail.birth.day
, &detail.birth.month, &detail.birth.year, &detail.balance, &detail.date.transday, &detail.date.transmonth, &detail.date.transyear)) != EOF)
{
if(strcmp(detail.acc_num,accnum) == 0)
{
printf("Name:%s\n", detail.name);
printf("Fees paid:");
scanf("%lf",&fees);
printf("Workbook paid:");
scanf("%lf",&workbook);
total = fees+workbook;
detail.balance += total;
|
|