|Department of Engineering|
|University of Cambridge > Engineering Department > computing help|
*aai is of type int. Note that:-
aai == *( (aai)+2) == *(*(aai+1)+2)and that numerically
aai == aai == &aai
*aai can be used as a pointer to the first element even though it is of type `array 4 of int' because it becomes `pointer to int' when used where a value is needed.
But *aai is not equivalent to a pointer. For example, you can't change its value. This distinction can easily and dangerously be blurred in multi-file situations illustrated in the following example. In
extern int *foo;foo is a variable of type pointer to int. foo's type is complete, (sizeof foo) is allowed. You can assign to foo. But given
extern int baz;baz is a variable of type `array UNKNOWN-SIZE of int'. This is an `incomplete' type, you can't take (sizeof baz). You cannot assign to baz, and although baz will decay into a pointer in most contexts, it is not possible for (baz == NULL) ever to be true.
The compiler will allow you to mix the array/pointer notation and will get it right, but it needs to know what the reality is. Once you declare the array/pointer correctly, you can then access it either way.