There're a lot of questions on SO about details of pointer and array declarations in C (and C subset of C++).
I'm more interested in why.
Why do we have to put *
, []
in front of every variable when we declare several pointers/arrays in a row?
int *a, *b;
int c[1], d[1];
Why do we have to type out things after/around variable names in function pointers?
void (*foo_ptr)(int, int);
Why do we have this feature that confuses a lot of newcomers, when even compilers recognize and report these things as part of type? Ex: function foo accepts int** but it was given int*
I guess I'm looking for intuition behind it that caused it being created this way, so that I can apply it to my understanding of the language. Right now I just don't see it...