C++ iomanip boolalpha Manipulator
Example
Print a boolean value with and without boolalpha:
bool isCodingFun = true;
cout << isCodingFun << "\n";
cout << boolalpha << isCodingFun;
Definition and Usage
The boolalpha manipulator prints bool values as the words true and false, instead of 1 and 0.
boolalpha keeps working for all the values printed after it.
The boolalpha manipulator is defined in the <ios> header file.
Tip: Use noboolalpha to go back to 1 and 0. Learn more about booleans in the Booleans chapter.
Syntax
cout << boolalpha;
You do not need to include <iomanip> to use boolalpha. It is available when you include <iostream>.
Parameter Values
None.
Technical Details
| Returns: | A reference to the stream (you do not use it directly). It changes all the bool values printed after it. |
|---|