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.
發佈了76 篇原創文章 · 獲贊 9 · 訪問量 28萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章