hi to all
i have stuggled a lot with the below code. just see the code and explanation and please tell me ur input on this
i have a code like this
void main()
{
const int i=10;
int *p=&i;
*p++;
Printf("%d",i);
}
value it will display is 10.
so here my question is accoriding to dennis the variable wich declare as const will be stored in codesigment(i.e read only memonry), means we cannot change the contents of the codesigment right??
here my question is then how come pointer(her pointer p wich is holding address of const variable i) here changing the value of "i" if it is stored in code segment.
i have asked lot of people but i didnt get the reply.. please send me as much as explanation as u people can
thanks in advance.
i have stuggled a lot with the below code. just see the code and explanation and please tell me ur input on this
i have a code like this
void main()
{
const int i=10;
int *p=&i;
*p++;
Printf("%d",i);
}
value it will display is 10.
so here my question is accoriding to dennis the variable wich declare as const will be stored in codesigment(i.e read only memonry), means we cannot change the contents of the codesigment right??
here my question is then how come pointer(her pointer p wich is holding address of const variable i) here changing the value of "i" if it is stored in code segment.
i have asked lot of people but i didnt get the reply.. please send me as much as explanation as u people can
thanks in advance.
Comment