Javatpoint Logo
Javatpoint Logo

C++ Manipulator boolalpha

C++ manipulator boolalpha function is used to set the output stream to display bool values as the strings "true" or "false"

Syntax

Parameter

str: stream object whose format flag is affected.

Return value

It returns argument str.

Data Races

Data races may be occurred when modified str concurrent accesses to the same stream object.

Exceptions

str is in a valid state, if an exception is thrown.

Example 1

Let's see the simple example to demonstrate the use of boolalpha:

Output:

When we use boolalpha then b = true
When we use noboolalpha then b = 1

Example 2

Let's see another simple example:

Output:

Output stream
-------------
1 true

Input stream
--------------
Enter a Boolean value: 0
Here is what you entered: false

Example 3

Let's see another simple example:

Output:

boolalpha true: true
boolalpha false: false
noboolalpha true: 1
noboolalpha false: 0
"true false" parsed as 1 0
Next TopicC++ Manipulator





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA