cout 修饰符不粘?

发布于 2024-08-22 05:16:01 字数 224 浏览 3 评论 0原文

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

将打印:

a

b

如果我cout 13,它将被打印为“c”。从现在开始,我如何删除十六进制修饰符,以便它只打印 13? 这可能很简单,但我尝试在其他地方寻找答案。谢谢。

  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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

何以心动 2024-08-29 05:16:01

在您的代码中写入:

cout << dec << 13

Write in your code:

cout << dec << 13
如梦亦如幻 2024-08-29 05:16:01

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.

狼性发作 2024-08-29 05:16:01
cout << dec

另请参阅此处

cout << dec

Also look here

旧情别恋 2024-08-29 05:16:01
using namespace std;
cout<<hex<<11<<endl;
cout<<dec<<12<<endl;
cout<<13<<endl;
using namespace std;
cout<<hex<<11<<endl;
cout<<dec<<12<<endl;
cout<<13<<endl;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文