I am writing a program for my intro to C class and keep getting some warnings when I try to compile with gcc.
Here is my code:
int main ()
{
float balance;
float beg_balance;
float withdrawal_amt;
float deposit_amt;
float amount;
int total_withdrawals;
int total_deposits;
int selection;
print_greeting ();
printf("Let's begin with your beginning balance");
beg_balance = get_positive_value();
do
{
print_menu ();
scanf("%d", &selection);
switch (selection)
{
case WITHDRAWAL:
get_positive_value();
balance = withdrawal(balance, withdrawal_amt, amount);
break;
case DEPOSIT:
get_positive_value();
balance = deposit(balance, deposit_amt, amount);
break;
case SUMMARY:
print_receipt(total_withdrawals, total_deposits, beg_balance, balance, \
withdrawal_amt, deposit_amt);
break;
case QUIT:
break;
default: printf("Invalid selection");
break;
}
}
while(selection != 4);
return 0;
The errors I am getting when compiling is this:
project.c: In function ‘main’:
project.c:46: warning: ‘withdrawal_amt’ may be used uninitialized in this function
project.c:46: warning: ‘amount’ may be used uninitialized in this function
project.c:50: warning: ‘deposit_amt’ may be used uninitialized in this function
project.c:53: warning: ‘total_withdrawals’ may be used uninitialized in this function
project.c:53: warning: ‘total_deposits’ may be used uninitialized in this function
Any ideas why? Thank you
EDIT:
Now i am having trouble creating a register function that is used to print out the transaction history of the account. It should print out the beginning and ending balances, as well as a table that shows all transactions (Deposits and Withdraws) that have occurred. Any help would be greatly appreciated