开发者

Unsticky a cout modifier?

  cout << hex << 11 << endl;
  cout << 12 << en开发者_高级运维dl;

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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜