C examples for Data Type:bool
The type _Bool stores Boolean values.
A Boolean value typically comes from a comparison where the result may be true or false.
The value of type _Bool can be either 0 or 1, corresponding to the Boolean values false and true, respectively.
Because the values 0 and 1 are integers, type _Bool is regarded as an integer type.
#include <stdio.h> int main(void) { bool valid = 1; // Boolean variable initialized to true printf("%d",valid); return 0; /*from ww w . ja v a 2 s .c om*/ }
You can assign integer value to _Bool type value.
#include <stdio.h> int main(void) { bool valid = 123; // Boolean variable initialized to true printf("%d",valid); return 0; /*from w w w . jav a 2s . c o m*/ }