Can we define boolean without a value?
CodePudding user response:
To use Boolean variables in C you need to #include <stdbool.h>
in your headers.
CodePudding user response:
In C, you can declare a boolean variable using the _Bool type. Following as an example. However, it is not a recommended method.
#include <stdio.h>
int main()
{
printf("Hello, World!\n");
_Bool k=0, l = 1, m = 324234;
printf("%d\n", k);
printf("%d\n", l);
printf("%d\n", m);
return 0;
}
You can further use a macro to define _Bool
as bool
.
#include <stdio.h>
typedef _Bool bool;
int main()
{
printf("Hello, World!\n");
bool k=0, l = 1, m = 324234;
printf("%d\n", k);
printf("%d\n", l);
printf("%d\n", m);
return 0;
}