Linux kernel code writes bowl. Is this okay?If you look at
From ANSI C99, _Bool
or stdbool.h
has _Bool
Then, where is the format specifier that makes it true/false instead of 1 or 0 output?
bool x = true;
printf("%B\n", x);
Output: true
C supports the boolean type, but there is no format specifier to output true
/false
.
In printf
, the format specifier for the bowl is usually %d
If you want to print it as true
/false
, you must specify it separately using a trigonometric operator
bool x = true;
printf("%d\n", x); // 1 output
// To output true or false, select any of the following:
printf(x ? "true" : "false");
//or
printf("%s", x ? "true" : "false");
//or
fputs(x ? "true" : "false", stdout);
© 2024 OneMinuteCode. All rights reserved.