关于修改 const 变量在 Xcode 和 visual studio上结果不同 - OurCoders (我们程序员)

OC

关于修改 const 变量在 Xcode 和 visual studio上结果不同

ingenium 发布于 2015年05月08日 | 更新于 2015年05月08日
无人欣赏。
#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

暂无回复
登录 或者 注册
发布新帖
相关帖子
相关新闻
最新帖子

AltStyle によって変換されたページ (->オリジナル) /