一.三个实验
1、直接对const变量修改
#include <stdio.h>
int main()
{
const int a = 10;
a = 1;
printf("a=%d",a);
}

还没有执行./xxx运行呢,编译就出错了。
2、const变量通过指针修改试验
#include
本文通过三个实验探讨了const变量在不同情况下的修改可能性。实验1和2表明,const变量在编译时期即受到约束,但通过指针可以绕过编译期检查。然而,实验3显示,尝试修改const全局变量会导致运行时段错误,因为全局const变量存储在只读内存中。
一.三个实验
1、直接对const变量修改
#include <stdio.h>
int main()
{
const int a = 10;
a = 1;
printf("a=%d",a);
}

还没有执行./xxx运行呢,编译就出错了。
2、const变量通过指针修改试验
#include
1966
1055

被折叠的 条评论
为什么被折叠?