Javatpoint Logo
Javatpoint Logo

C++ Manipulator noboolalpha

C++ manipulator noboolalpha function is used to set the output stream to display bool values as integers 0 or 1 (i.e. the default setting).

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 noboolalpha:

Output:

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

Example 2

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

Example 3

Let's see another simple example:

Output:

booleanValue is 1
booleanValue (after using boolalpha) is true

switch booleanValue and use noboolalpha

booleanValue is 0
booleanValue (after using boolalpha) is false
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