Archived

This topic is now archived and is closed to further replies.

Xero-X2

Pointer to Object

Recommended Posts

Xero-X2    184
int ME = 5;//make int
int *v=&ME;//make pointer to int
int d=v;   //make number equal to int that pointer points to (WARNING!)
 
Is there a way that I can do this. I have finally run into a problem that requires me to do this, normaly I find a way around it but This time there isn''t one. please help.

Share this post


Link to post
Share on other sites
MARS_999    1627
quote:
Original post by Xero-X2

int ME = 5;//make int
int *v=&ME;//make pointer to int
int d=v; //make number equal to int that pointer points to (WARNING!)


Is there a way that I can do this. I have finally run into a problem that requires me to do this, normaly I find a way around it but This time there isn't one. please help.


Your problem is your assiging a address to a variable.
do this

  
int ME = 5;
int *v = &ME;
int d = *v;


now d will have the value of *v and not the address. Hope that helps.

"You have Freedom, sir"
"Were do I have freedom"
"Only in your head, we control the rest of your body and life for now"
"My FREEDOM isn't for sale"

[edited by - Mars_999 on October 19, 2002 11:12:24 PM]

Share this post


Link to post
Share on other sites