문제

  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.

도움이 되었습니까?

해결책

Write in your code:

cout << dec << 13

다른 팁

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.

cout << dec

Also look here

using namespace std;
cout<<hex<<11<<endl;
cout<<dec<<12<<endl;
cout<<13<<endl;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top