?
Ce document utilise Manuel du site Web PHP chinois Libérer
C編程語(yǔ)言(從C99開(kāi)始)支持使用內(nèi)置類(lèi)型_Bool的布爾運(yùn)算(請(qǐng)參閱_Bool)。 當(dāng)包含頭文件<stdbool.h>時(shí),布爾類(lèi)型也可以作為bool訪(fǎng)問(wèn)。
標(biāo)準(zhǔn)邏輯運(yùn)算符&&
,||
,!
可以以任何組合的布爾類(lèi)型一起使用。
一個(gè)程序可能會(huì)取消定義,然后可能重新定義這些宏bool
,true
并且false
。
宏名稱(chēng) | 擴(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 ++文檔 |