Q2 – difference constant to pointer and pointer to constant ?



What is the difference between constant to pointer and pointer to constant?


No Pointer to Constant Constant Pointers
1 *ptr = 20 Statement is Invalid in Pointer to Constant i.e Assigning Value is Illegal *ptr = 20 is Absolutely Valid in Constant Pointers i.e Assigning Value is Perfectly legal
2 ptr ++  Statement  is Valid in Pointer to Constant ptr ++  Statement  is invalid in Constant Pointers
3 Pointer Can be Incremented and Decremented Pointer Cannot be Incremented and Decremented
4 Pointer is Pointing to Constant Data Object Constant Pointer is Pointing to Data Objects
5 Declaration : const int *ptr ; Declaration : int * const ptr ;