I am trying to make a craps game for school and my teacher/peers for some reason do not like using pointers.
I have the following code:
double get_wager_amount (void) {
double wager;
printf("How much would you like to wager?\n");
scanf(" %f", &wager);
return wager;
}
and would like to return the wager variable into another function that validates the wager amount based off of the amount in the user's bank account.
something like the code below but this obviously does not work because it re-prints everything that was in the wager and bank account function above.
int check_wager_amount (int *wager, int *account_balance)) {
double wager = 0, balance= 0;
if (wager <= get_wager_amount())
{
return 1;
} if (balance <= get_bank_balance())
{
return 0;
} else
{
printf("You either have no money or the program is not functioning correctly");
}
}
can someone please explain how to pass return values of functions to other functions via pointers or references? I cannot find any information on how to do this in C. Thank you.