什么是C代码的输出?我需要解释

Ram*_*ant 1 c

int main() 
{
    char boolean[][6]={"TRUE","FALSE"};
    printf("%s",boolean[(unsigned int)-1 == ~0]);
}
Run Code Online (Sandbox Code Playgroud)

执行后,我认为它为FALSE.是什么原因?

Jab*_*cky 11

因为

~0 == 0xffffffff  (the ~ operator inverts all bits)
Run Code Online (Sandbox Code Playgroud)

(unsigned int)-1 == 0xffffffff
Run Code Online (Sandbox Code Playgroud)

(0xffffffff == 0xffffffff) == 1
Run Code Online (Sandbox Code Playgroud)

你的表达归结为

boolean[1]
Run Code Online (Sandbox Code Playgroud)

结果

"FALSE"
Run Code Online (Sandbox Code Playgroud)