- The initial standards for the C programming language (1972) provided no Boolean type; and, to this day, Boolean values are commonly represented by integers (
int
s) in C programs. The comparison operators ('>
', '==
', etc.) are defined to return a signed integer (int
) result, either zero (for false) or 1 (for true). - ^ C99 added a
_Bool
type, but it was not retrofitted into the language's existing Boolean contexts. One can simulate a Boolean datatype, e.g. withenum { false, true } bool;
, but this does not provide all of the features of a separate Boolean datatype.
C中的Boolean type
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.