Use of bool in C
Prerequisite: Bool Data Type in C++
The C99 standard for C language supports bool variables. Unlike C++, where no header file is needed to use bool, a header file “stdbool.h” must be included to use bool in C. If we save the below program as .c, it will not compile, but if we save it as .cpp, it will work fine.
int main() { bool arr[2] = {true, false}; return 0; } |
chevron_right
filter_none
If we include the header file “stdbool.h” in the above program, it will work fine as a C program.
#include <stdbool.h> int main() { bool arr[2] = {true, false}; return 0; } |
chevron_right
filter_none
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above
Recommended Posts:
- Slack Bytes in Structures : Explained with Example
- Difference between Iterators and Pointers in C/C++ with Examples
- C program to count number of vowels and consonants in a String
- Nested Loops in C with Examples
- Hello World Program : First program while learning Programming
- Difference between Argument and Parameter in C/C++ with Examples
- Implicit Type Conversion in C with Examples
- <cfloat> float.h in C/C++ with Examples
- C/C++ #include directive with Examples
- C/C++ if else statement with Examples
- Internal static variable vs. External static variable with Examples in C
- C/C++ if statement with Examples
- C/C++ do while loop with Examples
- C/C++ while loop with Examples

