Hello all
How do I assign a variable to a specific memory address?
Printable View
Hello all
How do I assign a variable to a specific memory address?
Code:
int address = 1000;
int * ptr = (int*)address;
*ptr = 175; //... cross fingers :D ...
hehehe ;)Quote:
Originally posted by Sebastiani
Code:
int address = 1000;
int * ptr = (int*)address;
*ptr = 175; //... cross fingers :D ...
You could just do this:
But you shouldn't be doing this anyway. I saw this exact question on the boards earlier. Doing this is not a good idea if you don't know what you are doing. By virtue of the fact that you don't know how to do this I'd say that you shouldn't be doing this sort of thing.Code:
int *ptr = (int *)02400000; //yes this is an octal number, I never use them.
*ptr = ~*ptr;
// Should be in the video card range somewhere.
>>*ptr = ~*ptr;
What is this line used for, is the ~ the compliment.
So how does it work?
>>I saw this exact question on the boards earlier.
http://www.cprogramming.com/cboard/s...threadid=30224
What's the difference betwem
andCode:int address = 1000;
int *ptr = (int*)address;
- It may be because I haven't yet used CAST, but please explain.Code:int address = 1000;
int *ptr = address;
*EDIT*
Furthermore I don't get what the point is about this:
int *ptr = (int *)02400000;