Since the bool type in C is nothing else than an integer, a naive printout of the number will also just produce a number. This little trick gives you a text representation of the boolean value:
bool status = true;
printf("The status is %s", status ? "TRUE" : "FALSE");
The ternary operator is evaluated first. Since the value of status is true the string TRUE is the second argument of our printf.
Keine Kommentare:
Kommentar veröffentlichen