It's an accident of C syntax that you can write either int *i
or int* i
or even int * i
. All of them are parsed as int (*i)
; IOW, the *
is bound to the declarator, not the type specifier. This means that in declarations like
int* i, j;
only i
is declared as a pointer; j
is declared as a regular int. If you want to declare both of them as pointers, you would have to write
int *i, *j;
Most C programmers use T *p
as opposed to T* p
, since a) declarations in C are expression-centric, not object-centric, and b) it more closely reflects declaration syntax.
As an example of what I mean by expression-centric, suppose you have an array of pointers to int and you want to get the integer value at element i
. The expression that corresponds to that value is *a[i]
, and the type of the expression is int
; thus, the declaration of the array is
int *a[N];
When you see the phrase "declaration mimics use" with regard to C programming, this is what is meant.