I've got a test program to try this:
int main()
{
int i = 1;
int* p, q;
p = &i;
//q = &i;//q is not pointer
int* buf[20];//type of element is int*
return 0;
}
(1) I found q
is not pointer, so seems int *p
the asterisk is right-associative.
(2) But for int* buf[20]
, I found buf
an array of 20 elements, each typed with int*
. So in line 5, seems the asterisk is left-associative.
So what's the exact rule of how *
is associated with other parts of an expression, left-associative or right-associative, or apply to other rules?