Jump to content
  • Advertisement

Archived

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

robertgamble

Making a pointer point to a specific address?

This topic is 5902 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

How would I make a pointer point to a specific memory address? Say I have an integer "int *i" and when I assign a value to i it updates my memory address.. So instead of:- (int)(*0x5000)=new_value; I can do:- i=new_value; ..to write to 0x5000, Thanks.

Share this post


Link to post
Share on other sites
Advertisement
To make a pointer point to 0x5000 write this:

int* i = (int*)0x5000;

and now you can write:

*i = new_value;

to change the contents of adress 0x5000;

And thats it.



Jacob Marner, M.Sc.
Console Programmer, Deadline Games

Share this post


Link to post
Share on other sites
Do both of those cases work?

1. (int)(*0x5000)=new_value;

and

2.int *pi = reinterpret_cast(0x5000);

And could you tell me where the function "reinterpret_cast()"
comes from?

Thanks mates.

Share this post


Link to post
Share on other sites
hi, reinterpret_cast is a new keyword invented for c++ to get away from the old way of casting. There are four of them,

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!