People who have studied C or C + + know that when they first touch the pointer, they are always confused by constant pointers and pointer constants. Yesterday I thought of a way to make it easy for everyone to distinguish between the two.
First look at the two ways of writing:
Constant pointer:
int const *N, or const int *n;
Pointer constants:
int *const N;
Here we read the const as ' constant ', read the asterisk as a ' pointer ', read it in the order of the const and asterisks in the code (ignoring the other words) is just the right name for both, try it!
I believe that we can correct the code to distinguish what is a constant pointer, what is the pointer constant. If you are not familiar with the characteristics of constant pointers and pointer constants, check the data yourself, these are good distinctions.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A sentence distinguishes between constant pointers and pointer constants