为什么 (true && true) 引发错误而 (1 && 1) 不引发错误?
Why (true && true) raise an error while (1 && 1) doesn't?
我以为 C 将 true
解释为 1
但现在我有疑问了。
完整代码(使用 GCC 5.1 编译):
if(true && true) // Error: 'true' undeclared (first use in this function)
{
}
为什么会这样?
true
不像在 C++ 中那样是 C 中的关键字。
要访问它,您必须 #include <stdbool.h>
。
我以为 C 将 true
解释为 1
但现在我有疑问了。
完整代码(使用 GCC 5.1 编译):
if(true && true) // Error: 'true' undeclared (first use in this function)
{
}
为什么会这样?
true
不像在 C++ 中那样是 C 中的关键字。
要访问它,您必须 #include <stdbool.h>
。