Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
Miscellaneous
IOstream Library
manipulators
classes:
filebuf
fstream
ifstream
ios
iostream
ios_base
istream
istringstream
ofstream
ostream
ostringstream
streambuf
stringbuf
stringstream
objects:
cerr
cin
clog
cout
types:
fpos
streamoff
streampos
streamsize
manipulators
boolalpha
dec
endl
ends
fixed
flush
hex
internal
left
noboolalpha
noshowbase
noshowpoint
noshowpos
noskipws
nounitbuf
nouppercase
oct
resetiosflags
right
scientific
setbase
setfill
setiosflags
setprecision
setw
showbase
showpoint
showpos
skipws
unitbuf
uppercase
ws


dec

manipulator function
<ios>
ios_base& dec ( ios_base& str );

Use decimal base

Sets the basefield format flag for the str stream to dec.

When basefield is set to dec, integral numerical values inserted into the stream are expressed in the decimal base (radix 10). For input streams, extracted values are also expected to be expressed in the decimal base when this flag is set.

The basefield format flag can take any of the following values (each with its own manipulator):

flag valueeffect when set
decread/write integral values using decimal base format.
hexread/write integral values using hexadecimal base format.
octread/write integral values using octal base format.

The basefield flag is set to dec in standard streams on initialization.

Parameters

str
Stream object where to apply.
Because this function is a manipulator, it is designed to be used alone with no arguments in conjunction with the insertion (<<) and extraction (>>) operations on streams (see example below).

Return Value

A reference to the stream object.

Example

1
2
3
4
5
6
7
8
9
10
11
12
// modify basefield
#include <iostream>
using namespace std;
int main () {
  int n;
  n=70;
  cout << dec << n << endl;
  cout << hex << n << endl;
  cout << oct << n << endl;
  return 0;
}


The execution of this example displays something similar to:
70
46
106

See also