C Language Formatting Boolean Type

ht‮//:spt‬www.lautturi.com
C Language Formatting Boolean Type

We can create a macro to format boolean values

#define formatBool(b) ((b) ? "true" : "false")

printf("%i", true);  // output 1
printf("%i", false); // output 0

printf("%s", formatBool(true));  // true
printf("%s", formatBool(false)); // false
Created Time:2017-08-28 18:56:51  Author:lautturi