Browse Source

refactoring getAvailableBalance

remotes/origin/feature/send-money
fdai6618 2 years ago
parent
commit
47586c3d42
  1. BIN
      src/a.exe
  2. 33
      src/sendmoney.c
  3. BIN
      src/sendmoney.exe
  4. 2
      src/sendmoney.h

BIN
src/a.exe

33
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)

BIN
src/sendmoney.exe

2
src/sendmoney.h

@ -6,7 +6,7 @@
#include <string.h>
bool checkAccount(int accountNumber);
double getAvailableAccountBalance(double balance);
double getAvailableAccountBalance(int length);
double getAmount(double amountToSend);
void getReceiverAccountNumber();

Loading…
Cancel
Save