tags:

views:

123

answers:

4
  cout << hex << 11 << endl;
  cout << 12 << endl;

will print :

a

b

If I cout 13, it will be printed as 'c'. How do I remove the hex modifier from now on so it would just print 13? This is probably simple but I tried looking for the answer elsewhere. Thanks.

+1  A: 
cout << dec

Also look here

Drakosha
+1  A: 
using namespace std;
cout<<hex<<11<<endl;
cout<<dec<<12<<endl;
cout<<13<<endl;
Jacob
+5  A: 

write in your code

cout << dec << 13

zabulus
+4  A: 

You might want to look at the Boost iostream state saver library. This makes it fairly easy to save a state, set a new state, then restore the original (saved) state.

Jerry Coffin
This works in the general case, but seems overkill for just a change in base. +1 in any case.
Billy ONeal
@BillyONeal:If you really know that you're only going to change one thing, then it probably is overkill. Though it may have been incorrect, my assumption was that the base was an example, not necessarily the only attribute that would ever be involved.
Jerry Coffin
@Jerry Coffin: Which is why I gave you +1 ;)
Billy ONeal