#include <stdio.h>
int main(){
const int a = 10;
*(int*)(&a) = 9; //modify a
printf("%d", a);
return 0;
}
上面这段代码在VS里有效修改了a,结果为9
在Xcode里为10
为何
——————————————
stackoverflow 有点狠啊,一刷新就有答案了
http://stackoverflow.com/questions/30118051/modification-of-const-int-through-a-non-const-pointer