C语言中const修饰的常变量可以修改吗_c语言修改const常量-CSDN博客
1、const修饰的变量为只读,不能直接修改该变量的值。
2、const变量只不过是修饰该变量名,它并不能使内存变为只读。也就是说,我们不能通过变量名再去操作这块内存。但是可以通过其它方法,如指针,通过指针是可以修改被const修饰的那块内存的。
3、const 和 static 可以同时使用。为什么不能同时用const和static修饰成员函数?_为什么 cannot be both static and const-CSDN博客
int main()
{
const int a = 10;
a = 12;//错误! 不能直接通过变量名a去直接修改a的值
printf("a = %d\r\n",a);
//可以通过修改内存的方式修改
int *p = (int *)&a;
*p = 12;
printf("a = %d\r\n",a);
}