i have a question about constant variable in c/c++.The following is my code:
And the output is :Code:int main() { const int a = 10; int * p = (int*)&a; *p = 11; printf("the address of p = %p\n",p); printf("the address of a = %p\n",&a); printf("value of a = %d\n",a); printf("value of *p = %d\n",*p); return 0; }
I don't know why variable "a" and "p" have the same address but their value are different?Code:the address of p = 0xbfecca1c the address of a = 0xbfecca1c value of a = 10 value of *p = 11



LinkBack URL
About LinkBacks



