Browse Source

Merge branch 'feature/update-current-customer-account-balance' into feature/deposit-system

remotes/origin/feature/deposit-system
fdlt3817 2 years ago
parent
commit
8a84f5f257
  1. 2
      src/CustomerData.txt
  2. 7
      src/updateCustomerAccountBalance.c

2
src/CustomerData.txt

@ -3,7 +3,7 @@ ID=1234
forename=Max forename=Max
Surname=Mustermann Surname=Mustermann
password=example password=example
balance=4999
balance=5000
1327=example 1327=example
ID=1327 ID=1327

7
src/updateCustomerAccountBalance.c

@ -20,6 +20,7 @@ void replaceLineInFile(const char* file_name, int line, const char* new_line){
while (fgets(current_string, sizeof(current_string), file) != NULL) { while (fgets(current_string, sizeof(current_string), file) != NULL) {
if (current_line == line) { if (current_line == line) {
fprintf(temp_file, "%s", new_line); fprintf(temp_file, "%s", new_line);
fputs("\n", temp_file);
} else { } else {
fprintf(temp_file, "%s", current_string); fprintf(temp_file, "%s", current_string);
} }
@ -81,3 +82,9 @@ bool updateAvailableAccountBalance(int user_id, float changeInBalance, bool posi
float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance; float newBalance = (positive) ? availableBalance+changeInBalance : availableBalance-changeInBalance;
replaceBalanceInString(newBalance,currentLine); replaceBalanceInString(newBalance,currentLine);
} }
int main(){
updateAvailableAccountBalance(1234,500,true);
return 0;
}
Loading…
Cancel
Save