1. ## pointers

Hey guys if i declare

Code:
`int *px;`
does that mean px is a pointer to an int

Code:
`float *pa = &a;`
would that mean the address of &a is of pa which is a pointer to the float

2. Originally Posted by bazzano
Hey guys if i declare

Code:
`int *px;`
does that mean px is a pointer to an int
Yes.

Originally Posted by bazzano
Code:
`float *pa = &a;`
would that mean the address of &a is of pa which is a pointer to the float
If a is a float, then &a is the address of the float a, and in the initialization the float pointer pa would have a value of the address of a.

3. how about if its this

double *a[12] would that be a pointer to a pointer of type double because its an array

4. Originally Posted by bazzano

double *a[12] would that be a pointer to a pointer of type double because its an array
a is an array of 12 pointers to double. a[0], a[1], etc. is each a pointer to double.

A pointer to a pointer to a double is declared as double **a.

5. In general, the type is best understood by reading it from right to left:
[12] an array of twelve <- * pointers <- double to doubles.

6. I've come to think of it as kind of a spiral from the middle.
http://www.codeproject.com/cpp/compl...ight_left_rule

7. So if i have

Code:
`int [5] = {10,20,30,40,50}`
if i say
Code:
`(x + 2)`
would that give me 30

and if i go
Code:
`(*x + 2)`
will that make x point to the address of 30

but also how about if it was
Code:
`*(x + 2)`

8. Originally Posted by bazzano
So if i have

Code:
`int [5] = {10,20,30,40,50}`
if i say
Code:
`(x + 2)`
would that give me 30

and if i go
Code:
`(*x + 2)`
will that make x point to the address of 30

but also how about if it was
Code:
`*(x + 2)`
If you have
Code:
`int x[5] = {10,20,30,40,50}`
then
Code:
`(x + 2)`
is the address of the int containing 30.

If you have
Code:
`(*x + 2)`
that would be a value of 12.

If you have
Code:
`*(x + 2)`
that would be the value 30.

9. Could somone elaborate more please?

Code:
```#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int x[5] = {10,20,30,40,50};
int *y = (x + 2);
int z = (*x + 2);
int p = *(x + 2);
printf(" y = &#37;p\n", (void*)y);
printf("*y = %d\n", *y);
printf(" z = %d\n",  z);
printf(" p = %d\n",  p);
return 0;
}```
Sometimes you just need to look at something a couple hundred times before it is as clear as can be.

I know I have. And there are still more than a few things on the list.

11. Thanks mate

12. ## pointers

What i dont get is how you got 12 for Z

13. Originally Posted by bazzano
What i dont get is how you got 12 for Z
*x is 10
10 + 2 is 12

14. So does that int z = (*x+2)

x is alread pointing to the zeroth element in the array but because its a * its getting the value of x which is 10. Then adding 2 to ten.

And not incrementing where x is pointing too

15. Originally Posted by bazzano
So does that int z = (*x+2)

x is alread pointing to the zeroth element in the array but because its a * its getting the value of x which is 10. Then adding 2 to ten.

And not incrementing where x is pointing too
yes...