0为false,非0为true。
示例:
#include <stdio.h>
int main()
{
if(1)
{
printf("1 is true\n");
}
if(-1)
{
printf("-1 is true\n");
}
if(0)
{
printf("~~~\n"); // 不会执行到这里
}
else
{
printf("0 is false\n");
}
}
运行结果:
1 is true
-1 is true
0 is false