小编Mik*_*eri的帖子

为什么int的值会改变?

我有这个C代码:

int a = 5;
printf("a is of value %d before first if statement. \n", a);
if (a = 0) {
    printf("a=0 is true. \n");
}
else{
    printf("a=0 is not true. \n");
}
printf("a is of value %d after first if statement. \n", a);
if (a == 0){
    printf("a==0 is true. \n");
}
else{
    printf("a==0 is not true. \n");
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)

输出:

a is of value 5 before first if statement.
a=0 is not true. 
a is of …
Run Code Online (Sandbox Code Playgroud)

c

2
推荐指数
2
解决办法
140
查看次数

标签 统计

c ×1