📜  print bool - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:40.551000             🧑  作者: Mango

代码示例2
// there is no way of pretty-print a boolean with printf
printf("%i", true);  // will print 1
printf("%i", false); // will print 0

// but we can create a macro
#define formatBool(b) ((b) ? "true" : "false")
printf("%s", formatBool(true));  // will print true
printf("%s", formatBool(false)); // will print false