C++ Manipulator showbaseC++ manipulator showbase() function is used to set the showbase format flag for the str stream. It forces the base of an integral value to be output. Decimal values are output by default, octal numbers are output with a leading 0, and hexadecimal numbers are output with a leading ox. SyntaxParameterstr: stream object whose format flag is affected. Return valueIt returns argument str. Data RacesData races may cause when modifies str concurrent access 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 showbase: Output: 0x14 14 Example 2Let's see another simple example to demonstrate the use of stream manipulator showbase to force an integer to print in decimal, octal and hexadecimal formats: Output: Printing integers preceded by their base: 100 0144 0x64 Example 3Let's see another simple example: Output: showbase: 0x2a noshowbase: 2a With showbase, parsing 3.14 as money gives 0 Without showbase, parsing 3.14 as money gives 0
Next TopicC++ Manipulator
|