fif*_*c04 1 c c++ compiler-construction operators
我有
int x = 5;
printf("%d", x); //i get 5... expected
x = !x;
printf("%d", x);// i get 0... hmm
Run Code Online (Sandbox Code Playgroud)
二进制5是:0101如果我们对每个位应用反转,我们应该得到1010,但!
不一定是反相器,它是一个逻辑运算符.为什么我会得到一个0
?
是这样的原因,在C中,正数被视为真,所以!
它会导致0?这个编译器具体吗?