showbase

showbase

 

Indicates the notational base in which a number is displayed.


      ios
      _
      base& showbase(
   ios_base& _Str
);

_Str

A reference to an object of type ios_base, or to a type that inherits from ios_base.

A reference to the object from which _Str is derived.

The notational base of a number can be changed with dec, oct, or hex.

The manipulator effectively calls _Str.setf(ios_base::showbase), and then returns _Str.

Example

// ios_showbase.cpp
// compile with: /EHsc
#include <iostream>

int main( ) 
{
   using namespace std;
   int j = 100;

   cout << showbase << j << endl;   // dec is default
   cout << hex << j << showbase << endl;
   cout << oct << j << showbase << endl;

   cout << dec << j << noshowbase << endl;
   cout << hex << j << noshowbase << endl;
   cout << oct << j << noshowbase << endl;
}
100
0x64
0144
100
64
144

Requirements

Header: <ios>

Namespace: std

Show:
© 2016 Microsoft