Next: Pointer-Type Designators, Previous: Pointer Types, Up: Pointers [Contents][Index]
The way to declare that a variable foo points to type t is
t *foo;
To remember this syntax, think “if you dereference foo, using
the ‘*’ operator, what you get is type t.  Thus, foo
points to type t.”
Thus, we can declare variables that hold pointers to these three types, like this:
int *ptri; /* Pointer toint. */ double *ptrd; /* Pointer todouble. */ double (*ptrda)[5]; /* Pointer todouble[5]. */
‘int *ptri;’ means, “if you dereference ptri, you get an
int.”  ‘double (*ptrda)[5];’ means, “if you dereference
ptrda, then subscript it by an integer less than 5, you get a
double.”  The parentheses express the point that you would
dereference it first, then subscript it.
Contrast the last one with this:
double *aptrd[5];     /* Array of five pointers to double. */
Because ‘*’ has higher syntactic precedence than subscripting,
you would subscript aptrd then dereference it.  Therefore, it
declares an array of pointers, not a pointer.