Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) std::noboolalpha

 

std::noboolalpha is a stream manipulator to print the boolian values false and true as '0' and '1' instead of 'false' and 'true'.

 

 

 

 

 

Project and source code

 

Operating system: Ubuntu 10.04 LTS Lucid Lynx

IDE: Qt Creator 2.0.0

Project type: Qt4 Console Application

Compiler: G++ 4.4.1

Libraries used:

 

 

 

 

 

 

main.cpp

 

#include <iomanip>
#include <iostream>


int main()
{
  const bool f = false;
  const bool t = true;

  std::cout
    << "False: " << f << '\n'
    << "True: " << t << '\n';

  std::cout << std::boolalpha;

  std::cout
    << "False: " << f << '\n'
    << "True: " << t << '\n';
}

 

Screen output:

 

False: 0
True: 1
False: false
True: true

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict