C++ examples for File Stream:cout
Specifying Boolean Format, boolalpha
#include <iostream> #include <iomanip> int main(int argc, const char *argv[]) { bool booleanValue = true; // display default true booleanValue std::cout << "booleanValue is " << booleanValue << std::endl; // display booleanValue after using boolalpha std::cout << "booleanValue (after using boolalpha) is " << std::boolalpha << booleanValue << std::endl << std::endl;/*from w w w .j av a 2s . com*/ std::cout << "switch booleanValue and use noboolalpha" << std::endl; booleanValue = false; std::cout << std::noboolalpha << std::endl; // display default false booleanValue after using noboolalpha std::cout << "booleanValue is " << booleanValue << std::endl; // display booleanValue after using boolalpha again std::cout << "booleanValue (after using boolalpha) is " << std::boolalpha << booleanValue << std::endl; return 0; }