I hope this is my last question tho hahaha. okayy . so all the error are now gone and all, but the problem is, every users' balance value should be different right? but they all just print out the same value.
Is there anything wrong ? I only posted some of the codes(I'm sorry if it is too long, I don't know how to reduce for you guys to read), if there is no problem with it, then you can asked for the other codes.
struct bank_acc {
int accID; //"account ID"
char name[20];
float balance;
char password[10];
};
struct bank_acc accList[5] = { { 11111, "Susan Lee", 10000.0, "passwd1" },{ 22222, "James Mason", 20000.0, "passwd2" },{ 33333, "Jane Han", 30000.0, "passwd3" }};
int main(void)
{
int i;
printf("Welcome to Ewha Bank\n\n");
printf("1\tDeposit\n");
printf("2\tBalance\n");
printf("Choose an action\n");
scanf("%d", &i);
switch (i)
{
case 1: deposit();
break;
case 2: balance();
break;
}
return 0;
}
int login()
{
int result = FALSE;
int accID; //shortform of "account ID"
char password[10];
int count = 0;
do {
if (count == 3);
printf("\nPlease enter your account ID and password:");
scanf("%d %s", &accID, password);
for (int index = 0; index < 5; index++)
{
if (accID == accList[index].accID && strcmp(accList[index].password, password) == 0)
{
result = TRUE;
return result;
}
}
if (result == FALSE)
{
printf("\nThis account does not exist!\n");
count++;
}
if(count==3)
{
main();
}
} while (count);
return result;
}
void deposit()
{
int index;
float deposit, newbalance;
printf("\nPlease enter the amount you would like to deposit: \n");
scanf("%f", &deposit);
index = login();
if (index >= 0)
{
newbalance = deposit + accList[index].balance;
printf("\n***Your current balance is %.2f***\n", newbalance);
}
main();
}