bool in C language
For long time I was under an impression that bool
data type is present only in C++ and not in C language. I just got to know that it is there in C however it is not enabled default. So, we have to include it. It is very surprising that it is present there from C99 standard.
#include <stdio.h>
#include <stdbool.h>
int main(){
bool a = true;
printf("what's a? %d", a);
return 0;
}
Note
- Uninitialized bool defaults to
false
. - There is no format specifier in printf to specify bool type.