There is no format specifier for bool types. However, since any integral type shorter than int is promoted to int when passed down to printf()’s variadic arguments, you can use %d:
bool x = true;
printf(“%dn”, x); // prints 1
But why not:
printf(x ? “true” : “false”);
or, better:
printf(“%s”, x ? “true” : “false”);
or, even better:
fputs(x ? “true” : “false”, stdout);
instead?
There is no format specifier for bool. You can print it using some of the existing specifiers for printing integral types or do something more fancy:
printf(“%s”, x?”true”:”false”);