I am brand new to C++. I am trying to write a program to test the truth table and struggling with boolean type. I have the user input as T/F and program output as "True" or "False". I tried to use char for input/output, it works but it only allow "T" or "F". I also tried to use boolean, but the output is 0 or 1. How can I convert boolean to string in the output? Is there anyway to validate user input (not null) before the program run?
Sorry it has taken me so long to respond again. I'm just now messing with a custom boolalpha manipulator, but I have a question for you:
In C and C++, numbers may be represented in any of three bases: hex0x1Boct033dec27
However, the standard istreams are apparently too stupid to figure out the difference without some help from the programmer using the appropriate ios_base::hex, oct, and dec baseflags. And combining them (using istream::flags()) doesn't work either.
But, the whole point of the custom manipulator is to allow some automatic variations in recognized input format: accepting "true" or "True" or "yes" or "1" etc for true, and likewise "false" or "F" or "n" or "0" or whatever for false.
In the case that the input is numeric, should I consider the user's baseflags? If so, should I allow combinations?
Or should I just ignore the baseflags (seeing as we are reading a bool value, whether expressed as a number or as text) and accept any valid C++ formatted radix?
Your thoughs appreciated.  Right now I'm leaning towards the second option...[/edit]