Jan 6, 2009

const variable

int main(){
const int var=15;
int *p;
p=(int*)&var;
*p=10;
printf("%d %d\n",var,*p);
cout<<&var<<" "<<p<<endl;
}
15 10
0012FED4 0012FED4
I think compiler do some optimization on const variable
By the way. This is undefined

No comments:

Post a Comment