Javatpoint Logo
Javatpoint Logo

C++ Manipulator dec

C++ manipulator dec function is used to set the basefield format flag for the str stream.

When we set basefield to dec, then integer values inserted into the stream are expressed in decimal base (i.e. radix 10). For input stream, when this flag is set, then extracted values are also expected to be expressed in decimal base.

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

Output:

10000

Example 2

Let's see another simple example:

Output:

24
18
30

Example 3

Let's see another simple example:

Output:

The number 42 in octal:   52
The number 42 in decimal: 42
The number 42 in hex:     2a
Parsing "2A" as hex gives 42
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