Browse Source

Refactoring: minimize code lines for easy understanding

remotes/origin/feature/get-current-customer-account-balance
Shivam Chaudhary 2 years ago
parent
commit
8e0854cfc0
  1. 9
      src/currentCustomerAccountBalance.c

9
src/currentCustomerAccountBalance.c

@ -25,10 +25,9 @@ float readFileAndGetAvailableBalance(FILE *file, char stringID[MAX_LENGTH]) {
keep_reading = false;
}
else if(strstr(buffer, stringID)) {
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
fgets(buffer, MAX_LENGTH, file);
for (int i = 0; i < 4; i++) {
fgets(buffer, MAX_LENGTH, file);
}
strcpy(balance_String, buffer);
balance = fetchBalanceFromBalanceString(balance_String);
keep_reading = false;
@ -49,7 +48,7 @@ float getAvailableAccountBalance(int user_id) {
FILE *file = fopen("CustomerData.txt", "r");
if(file == 0) {
printf("Erro: file cannot be opened!");
printf("Error: customer data file cannot be opened!");
return 0;
}
else {

Loading…
Cancel
Save