Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / 关于const常量与指针赋值的问题

关于const常量与指针赋值的问题$gcc --version
gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.源码:#include <stdio.h>int main(int argc, const char *argv[])
{
 const int i = 1;
 int *p;
 p = &i;
 *p = 2;
 printf("%d ", i);
 printf("%d ", *p);
 return 0;
}貌似有点问题~~
 
如果换成g++编译则编译不通过,果然C++代码检查更严格。