Are
int (*x)[10];
and
int x[10];
equivalent?
According to the \"Clockwise Spiral\" rule, they parse
For me, it's easier to remember the rule as absent any explicit grouping, ()
and []
bind before *
. Thus, for a declaration like
T *a[N];
the []
bind before the *
, so a
is an N-element array of pointer. Breaking it down in steps:
a -- a
a[N] -- is an N-element array
*a[N] -- of pointer
T *a[N] -- to T.
For a declaration like
T (*a)[N];
the parens force the *
to bind before the []
, so
a -- a
(*a) -- is a pointer
(*a)[N] -- to an N-element array
T (*a)[N] -- of T
It's still the clockwise/spiral rule, just expressed in a more compact manner.