为什么(true && true)引发错误,而(1 && 1)不会? [重复]

问题描述 投票:-2回答:1
我以为C会将true解释为1,但现在我对此表示怀疑。

完整代码(与GCC 5.1编译):

if(true && true) // Error: 'true' undeclared (first use in this function) { }

为什么会这样?
c logical-operators
1个回答
2
投票
true不是C中的关键字,就像C ++中一样。

要访问它,您必须先#include <stdbool.h>

© www.soinside.com 2019 - 2024. All rights reserved.