Partager via


boolalpha

Specifies that variables of type bool appear as true or false in the stream.

ios_base& boolalpha(
   ios_base& _Str
);

Parameters

  • _Str
    A reference to an object of type ios_base, or to a type that inherits from ios_base.

Return Value

A reference to the object from which _Str is derived.

Remarks

By default, variables of type bool are displayed as 1 or 0.

boolalpha effectively calls _Str.setf(ios_base::boolalpha), and then returns _Str.

noboolalpha reverses the effect of boolalpha.

Example

// ios_boolalpha.cpp
// compile with: /EHsc
#include <iostream>

int main( ) 
{
   using namespace std;
   bool b = true;
   cout << b << endl;
   boolalpha( cout );
   cout << b << endl;
   noboolalpha( cout );
   cout << b << endl;
   cout << boolalpha << b << endl;
}

1
true
1
true

Requirements

Header: <ios>

Namespace: std

See Also

Concepts

<ios> Members

iostream Programming

iostreams Conventions