Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pointer help please!

Status
Not open for further replies.

ischneider

Programmer
Joined
Mar 27, 2006
Messages
1
Location
US
I need to pass the value of a pointer from one function to another.

I have it set up like this...

void GetTheMoney();
void FigureTheWinnings(int *, int &BetAmount);

void GetTheMoney()
{
int BetAmount, *BetAmt_ptr = &BetAmount;

cout << "\nEnter the amount you wish to bet.";
cin >> *BetAmt_ptr;
}

void FigureTheWinnings(int *, int &BetAmount)
{

cout<< (... i need BetAmount or *BetAmt_ptr here!? )

}

i think my protoype format is wrong can anyone show my the correct format.

please and thank you!
 
Code:
int BetAmount, *BetAmt_ptr = &BetAmount;
Don't declare multiple variables in one statement, especially if they are different types! It's confusing and an easy source of bugs.

Code:
void FigureTheWinnings(int *, int &BetAmount)
You aren't giving the first parameter a name, so how can you access it?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top