C++ Manipulator boolalphaC++ manipulator boolalpha function is used to set the output stream to display bool values as the strings "true" or "false" SyntaxParameterstr: stream object whose format flag is affected. Return valueIt returns argument str. Data RacesData races may be occurred when modified str concurrent accesses to the same stream object. Exceptionsstr is in a valid state, if an exception is thrown. Example 1Let'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 2Let's see another simple example: Output: Output stream ------------- 1 true Input stream -------------- Enter a Boolean value: 0 Here is what you entered: false Example 3Let'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
|