C中的Boolean type

  1. The initial standards for the C programming language (1972) provided no Boolean type; and, to this day, Boolean values are commonly represented by integers (ints) in C programs. The comparison operators ('>', '==', etc.) are defined to return a signed integer (int) result, either zero (for false) or 1 (for true).
  2. ^ 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. with enum { false, true } bool;, but this does not provide all of the features of a separate Boolean datatype.

你可能感兴趣的:(C中的Boolean type)