C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 27th, 2006, 05:44 PM
ischneider ischneider is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 1 ischneider User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 40 m 19 sec
Reputation Power: 0
Pointer help please.

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!

Reply With Quote
  #2  
Old March 27th, 2006, 10:04 PM
Cirus Cirus is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Posts: 276 Cirus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 48 m 58 sec
Reputation Power: 4
Quote:
Originally Posted by ischneider
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!


First of all where are you passing the BetAmout?? You are not callingFigureTheWinnings() from GetTheMoney.

Also in GetTheMoney() just do :
Code:
cin>>BetTheAmount; 


Since this will automatically give the value of the contents of the pointer.

Call to FiguretheWinning() would be
Code:

void FigureTheWinnings(BetAmt_Ptr, &BetAmount) ; 


From within the function GetTheMoney();

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Pointer help please.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT