Answers for "print booleen value in c"

C
8

how to print boolean in c

printf("%s", x ? "true" : "false");
Posted by: Guest on December-14-2020
3

print bool c

// 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
Posted by: Guest on November-30-2021

Code answers related to "C"

Browse Popular Code Answers by Language