开发者

Unsticky a cout modifier?

开发者 https://www.devze.com 2022-12-20 15:24 出处:网络
cout << hex << 11 << endl; cout << 12 << en开发者_高级运维dl; will print :
  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

精彩评论

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

关注公众号