What is the printf format specifier for bool?

前端 未结 8 761
有刺的猬
有刺的猬 2020-11-28 17:13

Since ANSI C99 there is _Bool or bool via stdbool.h. But is there also a printf format specifier for bool?

I mean

8条回答
  •  野性不改
    2020-11-28 17:54

    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");
    

提交回复
热议问题