Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/articles/c-tutorials/)
-   -   Constant and pointer (http://www.go4expert.com/articles/constant-and-pointer-t1578/)

kumardashish 21Oct2010 15:13

Re: Constant and pointer
your first program gives a warning because you r trying to store the address of const int variable into int type pointer.
here is the warning::" different 'const' qualifiers"
this is the reason you can change the value of const variable.if you create const type pointer variable then it gives an error : l-value specifier...
try this code..

void main()
    int const i=123;
    int *const ip;
    /* Changing constant integer i.e. const int/int const */
    printf(" %d %x \n",i,&i);
    printf(" %d %x %x %d \n",i,&i,ip,*ip);

itharsh_04 23Oct2010 15:41

Re: Constant and pointer
i like this formum
pl write & write all suggestion on my Eid itharsh_04@yahoo.com

All times are GMT +5.5. The time now is 13:57.