Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

c - C99 boolean data type?

What's the C99 boolean data type and how to use it?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Include <stdbool.h> header

#include <stdbool.h>

int main(void){
  bool b = false;
}

Macros true and false expand to 1 and 0 respectively.

Section 7.16 Boolean type and values < stdbool.h >

  • 1 The header <stdbool.h> de?nes four macros.
  • 2 The macro
    • bool expands to _Bool.
  • 3 The remaining three macros are suitable for use in #if preprocessing directives. They are
    • true : which expands to the integer constant 1,
    • false: which expands to the integer constant 0, and
    • __bool_true_false_are_defined which expands to the integer constant 1.
  • 4 Notwithstanding the provisions of 7.1.3, a program may unde?ne and perhaps then rede?ne the macros bool, true, and false.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...