what is difference between pointer to constant and constant pointer explain it with example? This very specific interview question for a c or c++ programmer.  It is a basic concept and every c/c++ developers must know. Let us discuss one by one.

If something is constant , it means it is not modifiable. const is a qualifier in c programming language. we also know that pointers in c are a variable which points to another variable.

 Pointer to constant

ptr is a pointer to a const int type. We can modify ptr itself but the object pointed to by ptr shall not be modified. 

constant pointer

So here ptr is constant and we cannot modify ptr. we can modify the object which is pointed by ptr.

constant pointer to constant variable

The declaration shows that neither ptr can be modified nor the variable at which it will point. Kindly see below code with example for each case.