?
This document uses PHP Chinese website manual Release
C編程語言(從C99開始)支持使用內(nèi)置類型_Bool的布爾運(yùn)算(請參閱_Bool)。 當(dāng)包含頭文件<stdbool.h>時,布爾類型也可以作為bool訪問。
標(biāo)準(zhǔn)邏輯運(yùn)算符&&
,||
,!
可以以任何組合的布爾類型一起使用。
一個程序可能會取消定義,然后可能重新定義這些宏bool
,true
并且false
。
宏名稱 | 擴(kuò)展到 |
---|---|
bool | _Bool |
true | 整數(shù)常量1 |
false | 整數(shù)常量0 |
__bool_true_false_are_defined | 整數(shù)常量1 |
#include <stdio.h>#include <stdbool.h> int main(void){ bool a=true, b=false; printf("%d\n", a&&b); printf("%d\n", a||b); printf("%d\n", !b);}
可能的輸出:
011
| 用于bool的C ++文檔 |