1 2 3 4

*

Similarly we can do things like:

int a[10][20];

pa = &a[0];

/* pa = &a[0][0];

*/

*

*

Then (*pa)[5]would be the same as a[0][5]

An observation: A variable should be used in a way that is consistent with its declaration (unlike the above!)

The type in a variable declaration is usually a basic type, the declaration syntax shows how a value of that basic type can be obtained from the variable name

Also note that [] has higher precedence than *. So

int (*pa)[20];
represents a pointer to an array of 20 integers. While

int* pa[20];/* and also int *pa[20]; */ is the declaration of an array of 20 pointers to integers

*

*

January 21, 1999

Page 2

copyright UoA