Making a pointer point to a specific address?
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.
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
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
Jacob Marner, M.Sc.Console Programmer, Deadline Games
This sounds like you''re doing something a bit dodgy, but still...
int *pi = reinterpret_cast(0x5000);
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.
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.
"... thats the rub...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement