cout<<std::hex<<dec;
我想将其存储为 0x 形式的 int...
如何将该值存储在整数中而不是将其打印出来?
如果您有一个整数值,并且想要打印它,只需执行以下操作(在 C 中):
int number = 555;
printf("%d",number); //this prints number in decimal
printf("%x",number); //this prints number in haxadecimal
你一定不要忘记,对于机器来说,只有0和1。
您只需定义您想要的打印方式
In C++:
int number = 555;
std::cout << std::hex << number << std::endl; //this will print the number in hexadecimal
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)