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:
- Arrow operator -> in C/C++ with Examples
- return statement in C/C++ with Examples
- size of char datatype and char array in C
- Logical Not ! operator in C with Examples
- Difference between C and C#
- scanf("%[^\n]s", str) Vs gets(str) in C with Examples
- time.h localtime() function in C with Examples
- Conditional or Ternary Operator (?:) in C/C++
- C program to Insert an element in an Array
- Types of Literals in C/C++ with Examples
- asctime() and asctime_s() functions in C with Examples
- time.h header file in C with Examples
- __builtin_inf() functions of GCC compiler
- Count substrings that contain all vowels | SET 2



