const
is to the left of *
, it refers to the value (it doesn't matter whether it's const int
or int const
)const
is to the right of *
, it refers to the pointer itselfAn important point: const int *p
does not mean the value you are referring to is constant!!. It means that you can't change it through that pointer (meaning, you can't assign $*p = ...`). The value itself may be changed in other ways. Eg
int x = 5;
const int *p = &x;
x = 6; //legal
printf("%d", *p) // prints 6
*p = 7; //error
This is meant to be used mostly in function signatures, to guarantee that the function can't accidentally change the arguments passed.