T
tigrfire
I don't want to use global variables to do this, but I'm stumped on how
to pass a variable between one function to another, so if someone could
help out, that'd be appreciated. Here's an example of what I need to
accomplish:
(note: Don't worry about whether or not the functions work properly,
but if you want to comment, I won't stop you.)
void playGame ()
{
int sum; /* sum of rolled dice */
int myPoint; /* point earned */
int balance; /* user's current balance */
..
..
..
}
void getWager()
{
int wager;
printf("Enter wager: ");
scanf("%d", &wager);
while (wager > balance || wager <= 0)
{
printf("Your wager must not exceed your current balance.\n");
printf("Enter a new wager: ");
scanf("%d", &wager);
}
}
to pass a variable between one function to another, so if someone could
help out, that'd be appreciated. Here's an example of what I need to
accomplish:
(note: Don't worry about whether or not the functions work properly,
but if you want to comment, I won't stop you.)
void playGame ()
{
int sum; /* sum of rolled dice */
int myPoint; /* point earned */
int balance; /* user's current balance */
..
..
..
}
void getWager()
{
int wager;
printf("Enter wager: ");
scanf("%d", &wager);
while (wager > balance || wager <= 0)
{
printf("Your wager must not exceed your current balance.\n");
printf("Enter a new wager: ");
scanf("%d", &wager);
}
}