1. ## understanding pointers

i don't really understand how to read pointers.. what does it really represent?
for example

Code:
```int num[5] = { 3, 4, 6, 2, 1 };
int* p = num;
int* q = num + 2;
int r = &num[1];```
what's the different if i printf num[2] and *(num+2).. or *p and *(p+1).. or *q+1 and *(q+1)..

2. OK, not 100&#37; if Im right here so dont take my word for it

*p gives you the value of what the pointer points to
*p+1 gives you the value plus 1, so if p points to 3 it will be 3 + 1
*(p + 1) gives you the value of the next element of the points. So if p points to num, *(p + 1) would print out 4.

i don't really understand how to read pointers.. what does it really represent?
I took me ages to get pointers and I still dont fully understand them. What it is is a address to a place in memory.

It is very very useful for passing big amounts of data around. Say you have a struct with 400 variables in it. If you pass that struct to a function you have to copy everything, but if you pass it as a pointer you only need to copy the address.

3. http://cpwiki.sourceforge.net/A_pointer_on_pointers
*(p + 1) <--- this basically takes the address stored in p, adds one, and then dereferences it (takes the value at the specified location).
*p+1 <-- this, as said, takes the value at the location at p and adds 1. The dereference operator has more precedence, so it happens first so to speak.

4. predecease => precedence.

And you should look at the difference in your question: you first compared num[2] and *(num+2), which are the same; so that means in the second case *(p+1) shouldn't compare to p+1, but "p[1]". (Since p points to num, "p[1]" means "num[1]" in this case.)

5. Nice, was looking for the word. I gave up when the dictionary didn't contain it, so I just picked the one that looked closest.

6. Originally Posted by Elysia
Nice, was looking for the word. I gave up when the dictionary didn't contain it, so I just picked the one that looked closest.
It's ok.. at least i still understand.. it do help me though..

7. if the code is like this

[code] int* p = &ary[3] [\code]

what does the '&' stands for? why some other does not have the '&'?

8. and another thing.. what the different if i printf p and i printf *p ? pointer is really hard for me..

9. & means the address of operator. It returns the address where an object is stored.
The index operator [] dereferences a pointer, also.

Originally Posted by princez90
and another thing.. what the different if i printf p and i printf *p ? pointer is really hard for me..
The * operator deferences a pointer, takes the value residing at the address where p points to.
Pointers are merely variables with an address stored. So if you want the value pointed to, you need to dereference using *.

10. using this program,

Code:
``` int num[5] = { 3, 4, 6, 2, 1 };
int* p = num;
int* q = num + 2;
int r = &num[1];```
does it mean p will return 3? what will *p return as? will it be 3 also?

11. p is a pointer, so it will return the location of num in memory.
*p is the thing pointed to, so it is 3 (since that's the first element of num, and p points at the start of the array).

12. No, p will contain the address of the start of the array.
*p will return the same as p[0], aka 3.

13. Originally Posted by Elysia
No, p will contain the address of the start of the array.
*p will return the same as p[0], aka 3.
so, p = 0??

14. Originally Posted by princez90
so, p = 0??
No, p would be something like "0x22ff22b" (the computer equivalent of "475 Elm Street").

15. p contains the address. If you print it out you get some number or hex decimal describing where that address is.
*p is what it points to

so:
int a = 0;
int *p = a;

printf a : An address, something like 010204923827 or what ever
printf *a : 0

Dont try to fully understand points if this is the first time you heard about them. Most people I know only looked at pointers as an address to something, and one day the whole concept just hit them. I think it comes by itself after some coding.