They are the same. The first one considers p
as a int *
type, and the second one considers *p
as an int
.
The second one tells you how C declarations simply work: declare as how would be used.
The Internet is flooded with complex approaches to parse declarations like "clockwise/spiral rule" and "the right rule". People makes the simple one complex: why do we need to read these types out loud? We only need to know how to use it!
By the way, the first one sometimes make you mad. Consider this:
int* p, q;
You would like p
and q
both becomes int *
, but unfortunately not.
If you write int *p, *q
, things will be simpler.
Anyway you can try this if you insists on approach one.
typedef int* intp;
intp p, q;