Best way to print the result of a bool as 'false' or 'true' in c?

You could use C's conditional (or ternary) operator.

This worked for the at_least and negative functions, but not for the between function. I have void between(int x, bool* bet) { if (x >= LOWER && x – Piseagan Oct 1 at 20:28.

"true" : "false"); or printf(" ... %s ... ", x?"true" : "false"); You may want to make a macro for this.

1. ................. – Mitch Wheat Oct 1 at 1:20 Technically it's a const char*, not a char* (though there is a deprecated conversion from the former to the latter), but that's irrelevant here. – Adam Rosenfield Oct 1 at 1:23 There's no point in creating a macro when an inline function can do the job.

– kevin cline Oct 1 at 1:49 1 No, it's char *. This is C not C++. – R.. Oct 1 at 4:44.

Very unreadable though. But nice solution otherwise. – DeCaf Oct 1 at 14:49 2 An inline function or macro with a self-documenting name (e.g. Bool2str) would fix that.

– R.. Oct 1 at 15:07 Very true indeed. :) – DeCaf Oct 1 at 17:38.

"true" : "false" int main(int iArgC, char ** ppszArgV) { int x = 0; printf(BOOL_FMT(x)); int y = 1; printf(BOOL_FMT(y)); return 0; } This prints out the following: x=false y=true Using this with type bool but int should work the same way.

You probably want to add the printf call into the macro. Although because of how the comma operator works, you can use extra parentheses to do stuff like puts((BOOL_FMT(1))) to print true. – Oscar Korz Oct 1 at 17:27.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions