The access modifier keyword const is a promise the programmer makes to the compiler that the value of a variable will not be changed after it is initialized. The compiler will enforce that promise as best it can by not enabling the programmer to write code which modifies a variable that has been declared const.
A ?const pointer,? or more correctly, a ?pointer to const,? is a pointer which points to data that is const (constant, or unchanging). A pointer to const is declared by putting the word const at the beginning of the pointer declaration. This declares a pointer which points to data that can?t be modified. The pointer itself can be modified. The following example illustrates some legal and illegal uses of a const pointer:
Pointer Constant is a pointer which points to the same location everytime. The address in the pointer variable can't be changed. Ex: int a=10,b=20; int const *p=&a; a=30;//Legal p=&b//Illegal: p a constant pointer always points to the same location
But, Constant pointer always points to a value which cannot change i.e. the pointer can point to any variable but the value of the variable it points to cannot change.
Ex: int a=10,b=20; const int *p=&a; a=30;//Illegal as p is a constant pointer the value it points to cannot change p=&b;//Legal