quote:
Original post by Mythril
maybe i am dumb, or just too much of a novice, but i still do not understand pointers. i know that they allow memory allocation(forgive me if that is the wrong wording) but i dont know why this is so useful, or how it is implemented.
the way i see it is that you make a pointer. then a variable that holds a value. then i believe the pointer holds the address of the variable. and by accessing the pointer, you access the value of the variable?
i have read articles in the reference section here, and they do nothing for me. if you guys would help me understand how they get the address, and the true advantages for these pointers in gaming and other programming, i would be much abliged.
Mythril
Ok, let''s assume we are working on a 32 bit platform. The reason it''s called a 32 bit platform and not a 16 bit platform is because it uses 32 bits to address memory, not 16 (like win 3.1)
16 bits:
0000000000000000
32 bits:
00000000000000000000000000000000
16 bits means you can have 65535 memory locations, where as with 32 bits, you can have 4294967295 memory locations.
So here''s what a pointer is: in a 32 bit system, a pointer is the 32 bit handle to the memory location.
Ok, we know where the memory is located, how do we know how long it is? Well, that''s why we cast pointers of certain types. We know that a pointer to a long value is a 32 bit memory location address of that long and the compiler knows to read the length of a long when accessing that variable.
How do you get the address of a variable? Well man, if this is the first time you are playing with them, I wouldn''t even bother with them. Read the other posts to see how dangerous and unnecessary pointers really are.