What\'s the difference between:
char * const
and
const char *
Lots of answer provide specific techniques, rule of thumbs etc to understand this particular instance of variable declaration. But there is a generic technique of understand any declaration:
Clockwise/Spiral Rule
A)
const char *a;
As per the clockwise/spiral rule a
is pointer to character that is constant. Which means character is constant but the pointer can change. i.e. a = "other string";
is fine but a[2] = 'c';
will fail to compile
B)
char * const a;
As per the rule, a
is const pointer to a character. i.e. You can do a[2] = 'c';
but you cannot do a = "other string";