小编Dee*_*ama的帖子

这段代码的“假”输出背后的原因是什么?

此 C 代码给出输出“False”并且else块正在执行。

的值为sizeof(int)4,但 的值为sizeof(int) > -10。

我不明白发生了什么。

#include <stdio.h>
void main()
{
    if (sizeof(int) > -1 )
    {
       printf("True");
    }
    else
    {
        printf("False");
    }
    printf("\n%d", (sizeof(int)) ); //output: 4
    printf("\n%d", (sizeof(int) > -1) ); //output: 0
}
Run Code Online (Sandbox Code Playgroud)

c comparison unsigned gcc sizeof

4
推荐指数
1
解决办法
81
查看次数

0
推荐指数
1
解决办法
105
查看次数

标签 统计

c ×1

c++ ×1

comparison ×1

gcc ×1

sizeof ×1

unsigned ×1