[Help]pointers

Posts 1–7 of 7 · Page 1 of 1
[Help]pointers
so i know the basics of pointers and what they do.
i just don't know why they are used in some ways.
for example: (int*)[addy]
does this mean that it is a pointer to the address with a int value?
and also: *(int*)[addy] - what does this mean?
thanks in advance
[php]
(int*)(Address)
[/php]

Casting the address as a pointer so you can point to it.

[php]
*(int*)(Address)
[/php]

Pointing to the pointer-casted address.
so
Code:
int * x = *(int*)[addy]
is the same as
Code:
int * x = &y
NO! definitly NOT!!!

example:
Code:
int * pVal = 0x337456;
that means that pVal is a pointer to an int variable
pVal is = 0x337456 so it points to your memory at 0x337456 and
Code:
int cont = *pVal;
gives you the content of pVal
Code:
int Var = 0;
int * pVal = &Var; //the & gives you the address of Var so pVal is now the address of Var

int content = *pVal; //Now in content you got the content of the pointer where pVal points to. It is the same as
int content = Var;
For you example:
Code:
int * x = *(int*)ADDY;
results in the same as
Code:
int * x = y;
and
Code:
int * x = &y;
writes in x the address of y
with
int z = *x;
you can get the value that is in y
I hope I helped you a bit but the best way to learn with pointers is to try some easy programmes with it.

EDIT:
i found this on google:
credits of this pic to
tenouk.com or so...
Holy fuck I hate pointers, I use them all the time and I still don't understand this shit.
~lilneo
Lol, they're so easy >.>
Posts 1–7 of 7 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us