如何将整数的十进制转换为整数的十六进制? [英] How do you convert decimal in integer to hexadecimal in integer?
本文介绍了如何将整数的十进制转换为整数的十六进制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
cout<<std::hex<<dec;
我想将其以0x的形式存储到一个int ...
I want to store it to an int in the form of 0x...
如何将该值存储为整数而不是将其打印出来?
How do I store that value in an integer instead of printing it out?
推荐答案
您可以先将值存储到字符串流中:
You can store the value into a string stream first:
#include <stringstream>
std::stringstream ss;
ss << std::hex << dec;
int n;
ss >> n;
这篇关于如何将整数的十进制转换为整数的十六进制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文