Javatpoint Logo
Javatpoint Logo

C++ Manipulator showbase

C++ 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.

Syntax

Parameter

str: stream object whose format flag is affected.

Return value

It returns argument str.

Data Races

Data races may cause when modifies str concurrent access 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 showbase:

Output:

0x14
14

Example 2

Let'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 3

Let'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





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