Boolean values

suggest change

C23 provides bool as a type keyword and true and false as predefined constants. No header is required:

bool ready = false;

if (!ready) {
    ready = true;
}

In C99 through C17, include <stdbool.h> to obtain the bool, true, and false macros. The underlying built-in type in those language versions is _Bool:

#include <stdbool.h>

bool ready = false;

Converting any scalar value to bool or _Bool produces false for zero and true for every nonzero value. Do not create a custom Boolean typedef in modern C; the standard facilities communicate intent and interact correctly with conversions.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents