- 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
最新推荐文章于 2024-01-24 12:24:15 发布