Mega Code Archive

 
Categories / C++ Tutorial / Development
 

Demonstrating stream-manipulators boolalpha and noboolalpha

#include <iostream> using std::boolalpha; using std::cout; using std::endl; using std::noboolalpha; int main() {    bool booleanValue = true;    cout << "booleanValue is " << booleanValue << endl;    cout << "booleanValue (after using boolalpha) is "<< boolalpha << booleanValue << endl << endl;    booleanValue = false; // change booleanValue    cout << noboolalpha << endl; // use noboolalpha    cout << "booleanValue is " << booleanValue << endl;    cout << "booleanValue (after using boolalpha) is " << boolalpha << booleanValue << endl;    return 0; } booleanValue is 1 booleanValue (after using boolalpha) is true booleanValue is 0 booleanValue (after using boolalpha) is false