const usage with pointers in C

const char* is, as you said, a pointer to a char, where you can’t change the value of the char (at least not through the pointer (without casting the constness away)).

char* const is a pointer to a char, where you can change the char, but you can’t make the pointer point to a different char.

const char* const is a constant pointer to a constant char, i.e. you can change neither where the pointer points nor the value of the pointee.

Leave a Comment