After several years I found lots of people – and me 🙂 – still confused about the pointer declarations – if it contains some const keyword somewhere.
So const char * or char const * or char * const still confusing.
To keep it simple: read it backward as this excellent post describes: Clockwise/Spiral rule
- const char * is equivalent to char const * : pointer to a constant character (character constant). It means you can change the pointer – so it points to somewhere else – but cannot change the memory at that address.
- char * const : constant pointer to a character. It means you cannot change the pointer value – but you can change the memory at that address
- const char * const which is equal to char const * const is the one where you cannot change anything – constant pointer to a constant character.