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:
- getch() function in C with Examples
- Chain of Pointers in C with Examples
- Pointer Expressions in C with Examples
- Speed up Code executions with help of Pragma in C/C++
- Introduction to the C99 Programming Language : Part I
- Jagged Array or Array of Arrays in C with Examples
- Introduction to the C99 Programming Language : Part III
- Introduction to the C99 Programming Language : Part II
- Features of C Programming Language
- Difference between Increment and Decrement Operators
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- Predefined Macros in C with Examples
- How to create GUI in C programming using GTK Toolkit

