const问题
#include <stdio.h>int main()
{
const int a = 10;//a的值应该是不可改写的吧?
int * b = &a;
(*b)++;
printf("%d\n",a);
}
为什么最后编译通过(产生一条警告信息),执行还是会改变a的值呢?
2010-10-13 08:26
2010-10-13 08:43

2010-10-13 09:03
程序代码:#include<stdio.h>
#include<malloc.h>
int main()
{
volatile const int a=0;
int b[1];
b[1]=1;
printf("%d\n",a);
return 0;
}
2010-10-13 09:22
2010-10-13 10:24

2010-10-13 15:26

2010-10-13 15:49
可在vc6下编译你的代码,是按error提示的,而且不让运行的。
2010-10-13 16:35
2010-10-14 11:02
2010-10-14 13:06