Undaunted cout modifier?

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

will print:

and

b

If I cout 13, it will be printed as 'c'. How to remove the hex modifier from now on so that it just prints 13? This is probably simple, but I tried to find the answer elsewhere. Thank.

+3
source share
4 answers

Write in your code:

cout << dec << 13
+5
source

You might want to check out the Boost iostream state saver library . This allows you to easily save the state, set a new state, and then restore the original (saved) state.

+5
source
cout << dec

+1
using namespace std;
cout<<hex<<11<<endl;
cout<<dec<<12<<endl;
cout<<13<<endl;
+1

Source: https://habr.com/ru/post/1733129/


All Articles