Wikipedia claims that the [] operator precedes the * operator in evaluation.
Then, why does the following statement:
char *a[3];
declare an array of 3 character pointers, rather than a pointer to an array of 3 characters as per the operator precedence?
Because, as Wikipedia says,
[]has higher precedence than*?Processing the declaration, the
a[3]is processed as ‘array of 3’ before you process the*.To declare a pointer to an array of three characters, you have to use parentheses to override the default precedence:
Now the parentheses take precedence over the array.