Boolean values
suggest changeC23 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents