Differences Between “const char * p” and “char const * p” and “char * const p”

In C/C++ programing, const is a keyword refers to a variable that is constant (cannot be changed"). The meaning of the positioning of the “const” keyword is following:

1. const char * p: This means that the pointer “p” is pointing to a constant character. The character is not modifiable, but the pointer can.

2. char const * p: This means the same as in 1.

3. char * const p: It means that the pointer “p” is constant which points to a character. The character is modifiable, but the pointer cannot.

The meaning of the code can be interpreted by reading the code from your right hand side to your left hand side.


One thought on “Differences Between “const char * p” and “char const * p” and “char * const p”

Leave a Reply

Your email address will not be published. Required fields are marked *