我能够const在gcc 中更改修改变量的值,但在其他编译器中却没有.我在gcc上尝试了这个代码,它更新了i和j(11)的值.使用在线编译器,我得到不同的值.
#include<stdio.h>
void main() {
const int i=10;
int *j;
j = &i;
(*j)++;
printf("address of j is %p address of i is %p\n",j,&i);
printf("i is %d and j is %d\n",i,*j);
}
Run Code Online (Sandbox Code Playgroud)