A constant pointer is one that cannot change the address it contains. The qualifier const can be applied to the declaration of any variable to specify that its value will not be changed ( Which depends upon where const variables are stored, we may change the value of const variable by using pointer ). The result is implementation-defined if an attempt is made to change a const.
//Const #include<stdio.h> int main() { //Case 3: char a[3]={'a','b','c'}; char * const p=a; printf("\n *p = %c",*p); *p='x'; //p++; //Cannot change the value its const printf("\n *p = %c",*p); return 0; } /* //Case 1: char a[3]={'a','b','c'}; const char *p=a; printf("\n *p = %c",*p); //*p='x'; // Cannot change the value its const p++; printf("\n *p = %c",*p); */ /* //Case 2: char a[3]={'a','b','c'}; char const *p=a; printf("\n *p = %c",*p); //*p='x'; // Cannot change the value its const p++; printf("\n *p = %c",*p); */To download raw file Click Here
*p = a *p = x
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions