Data Types
Booleans
stdbool.h provides the bool, true, and false names for clear yes/no state.
Booleans
booleans.c
#include <stdbool.h>
#include <stdio.h>
int main(void) {
bool enabled = ;
const char *label = enabled ? "enabled" : "disabled";
printf("flag=%s\n", label);
return 0;
}
#include <stdbool.h>
#include <stdio.h>
int main(void) {
bool enabled = ;
const char *label = enabled ? "enabled" : "disabled";
printf("flag=%s\n", label);
return 0;
}
stdbool
`#include <stdbool.h>` defines `bool`, `true`, and `false`.
ternary
The ternary operator chooses one of two values based on a condition.