What is happening is that when you read a char for "do you want to do another transaction" it is returning the next character from the last scanf. You can fix this by making sure that unused characters are flushed. One way to do this is to add
void flush_stdin()
{
int c;
while ((c = fgetc(stdin)) != '\n' && c != EOF);
}
and call it after every scanf. Now, this may not be the best way (my C is quite rusty). I have a few m ore comments...
In the following:
case 'w':case 'W':
printf("How much would you like to withdraw?\n");
if (((withdrawal== 0) || (withdrawal== -1))){
printf("You have insufficient funds");
}
you haven't done any input for withdrawal.
In the following, balance needs to have an initial value.
case 'b':case 'B':
printf("Checking your account balance\n");
balance=displaybalance(balance);
break;
Same thing for amount here
case 'd':case 'D':
printf("How much would you like to deposit?\n");
deposit=getdeposit(amount,balance);
break;
I strongly suggest you adopt a consistent formatting style. You are using both the
statement {
statement
}
form as well as
statement
{
statement
}
form. Use one or the other. Not both.