C stdbool (stdbool.h) Library
C stdbool Macros
The <stdbool.h> header lets you use bool, true and false in C. Without it, you must use the _Bool keyword, and 1 and 0.
Example
Use bool, true and false:
bool isRaining = true;
bool isSunny = false;
printf("%d\n", isRaining);
printf("%d\n", isSunny);
| Macro | Description |
|---|---|
| bool | The same as the _Bool type. It stores 1 (true) or 0 (false) |
| true | The value 1 |
| false | The value 0 |
Note: In C23 (the newest version of C), bool, true and false are keywords, so you do not need <stdbool.h>. Programs that include it still work.
Related Pages
Read more about booleans in our C Booleans Tutorial.