|
ANSI C中是没有bool类型的,C99中引入了bool类型,具有true(也就是1)和false(也就是0)两种值,但是需要包含头文件stdbool.h之后才可以使用。
我们完全可以用枚举类型来模拟bool类型,如下所示:
typedef enum{
false, true
}bool;
bool test(int a)
{
if(a > 0){
return true;
}
else{
return false;
}
}
int main(void)
{
bool result;
result = test(1);
return 0;
}
|