Archived

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

Pointer to Object

This topic is 5535 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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
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