diff --git a/src/CustomerData.txt b/src/CustomerData.txt index 51ffa90..911b18e 100644 --- a/src/CustomerData.txt +++ b/src/CustomerData.txt @@ -3,7 +3,7 @@ ID=1234 forename=Max Surname=Mustermann password=example -balance=4999 +balance=5000 1327=example ID=1327 diff --git a/src/updateCustomerAccountBalance.c b/src/updateCustomerAccountBalance.c index 9c868b2..566f2fd 100644 --- a/src/updateCustomerAccountBalance.c +++ b/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) { if (current_line == line) { fprintf(temp_file, "%s", new_line); + fputs("\n", temp_file); } else { 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; replaceBalanceInString(newBalance,currentLine); } +int main(){ + + updateAvailableAccountBalance(1234,500,true); + + return 0; +} \ No newline at end of file