Since ANSI C99 there is _Bool
or bool
via stdbool.h
. But is there also a printf
format specifier for bool?
I mean something like in that pseudo code:
bool x = true;
printf("%B\n", x);
which would print:
true
booleancprintf
Since ANSI C99 there is _Bool
or bool
via stdbool.h
. But is there also a printf
format specifier for bool?
I mean something like in that pseudo code:
bool x = true;
printf("%B\n", x);
which would print:
true
Best Answer
There is no format specifier for
bool
types. However, since any integral type shorter thanint
is promoted toint
when passed down toprintf()
's variadic arguments, you can use%d
:But why not:
or, better:
or, even better:
instead?