diff --git a/src/a.exe b/src/a.exe index 9ac4170..0763b24 100644 Binary files a/src/a.exe and b/src/a.exe differ diff --git a/src/sendmoney.c b/src/sendmoney.c index cdc75e5..127700e 100644 --- a/src/sendmoney.c +++ b/src/sendmoney.c @@ -3,10 +3,35 @@ int main() { SendMoney(); } -double getAvailableAccountBalance(double balance) +double getAvailableAccountBalance(int length) { + double availableBalance; - return balance; + FILE *fp; + fp = fopen("CustomerData.txt", "r"); + + if (fp == 0) + { + printf("Error: customer data file cannot be opened!\n"); + return 0; + } + else + { + + char line[length]; + + while (fgets(line, sizeof line, fp) != NULL) + { + if (sscanf(line, "balance=%lf", &availableBalance) == 1) + { + break; + } + } + fclose(fp); + printf("your balance is : %lf\n", availableBalance); + } + + return availableBalance; } // hier wird geprüft ob das Kontonummer gultig ist @@ -48,7 +73,7 @@ void getReceiverAccountNumber() else { - printf("Kontonummer ist Gueltig"); + printf("Kontonummer ist Gueltig\n"); } } @@ -65,8 +90,6 @@ void SendMoney() int receiverAccountNumber; double availableAccountBalance = getAvailableAccountBalance(length); - printf("%lf", availableAccountBalance); - char tryDifferentAmount; if (amountToSend < 0) diff --git a/src/sendmoney.exe b/src/sendmoney.exe index 249c344..ebd1eb9 100644 Binary files a/src/sendmoney.exe and b/src/sendmoney.exe differ diff --git a/src/sendmoney.h b/src/sendmoney.h index e4cc9e7..2a602fc 100644 --- a/src/sendmoney.h +++ b/src/sendmoney.h @@ -6,7 +6,7 @@ #include bool checkAccount(int accountNumber); -double getAvailableAccountBalance(double balance); +double getAvailableAccountBalance(int length); double getAmount(double amountToSend); void getReceiverAccountNumber();