There is no bool data type in C. In C99 standerd version, the boolean variable has been added as _Bool. Additionally, a new header stdbool.h has been added for compatibility reasons. This header allows programmers to use boolean types in the same way, as in C++ language.
To use bool in C, we can use enum as below.
1 2 3 4 5 6 7 8 9 10 11 12 | enum bool { false, true }; bool value; value = bool(0); // False value = bool(1); // True if(value == false) printf("Value is false"); else printf("Value is true"); |
Here we can use variable ‘value’ as boolean variable.