format bool c
#include <stdbool.h>
#include <stdio.h>
int main() {
bool b1 = true;
bool b2 = false;
printf("b1: %d\n", b1);
printf("b2: %d\n", b2);
return 0;
}
This is a simple example of how to use the bool
data type in C. The bool
type is defined in the stdbool.h
header file and can hold either true
or false
values. In this example, we declare two bool
variables b1
and b2
, initialize them with true
and false
values respectively, and then print their values using the %d
format specifier in the printf
function. The output will be 1
for true
and 0
for false
.