Go4Expert

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
 
hi..
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..
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);
    ip=&i;
    *ip=456;
    printf(" %d %x %x %d \n",i,&i,ip,*ip);
   
}


itharsh_04 23Oct2010 15:41

Re: Constant and pointer
 
hi,
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 05:44.