|
@ -44,10 +44,9 @@ void replaceBalanceInString(float replacementBalance, int currentLine) { |
|
|
replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine); |
|
|
replaceLineInFile("CustomerData.txt",currentLine,newBalanceLine); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool positive){ |
|
|
|
|
|
|
|
|
bool updateAvailableAccountBalance(int user_id, float newBalance){ |
|
|
|
|
|
|
|
|
bool keep_reading = true; |
|
|
bool keep_reading = true; |
|
|
float availableBalance = 0; |
|
|
|
|
|
|
|
|
|
|
|
char buffer[MAX_LENGTH]; |
|
|
char buffer[MAX_LENGTH]; |
|
|
char stringID[MAX_LENGTH] = "ID="; |
|
|
char stringID[MAX_LENGTH] = "ID="; |
|
@ -73,18 +72,10 @@ bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool posi |
|
|
fgets(buffer, MAX_LENGTH, file); |
|
|
fgets(buffer, MAX_LENGTH, file); |
|
|
strcpy(balance_String, buffer); |
|
|
strcpy(balance_String, buffer); |
|
|
currentLine+=4; |
|
|
currentLine+=4; |
|
|
availableBalance = fetchBalanceFromBalanceString(balance_String); |
|
|
|
|
|
keep_reading = false; |
|
|
keep_reading = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
fclose(file); |
|
|
|
|
|
float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance; |
|
|
|
|
|
|
|
|
fclose(file);; |
|
|
replaceBalanceInString(newBalance,currentLine); |
|
|
replaceBalanceInString(newBalance,currentLine); |
|
|
} |
|
|
} |
|
|
int main(){ |
|
|
|
|
|
|
|
|
|
|
|
updateAvailableAccountBalance(1234,500,true); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
} |
|
|
|