将hex转换为dec C ++ [英] Converting hex to dec C++

查看:204
本文介绍了将hex转换为dec C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

转换为十六进制:

cout << hex << int(x) << endl;

如何转换,从十六进制到十六进制?

How to convert conversely, from hex to dec?

输入十六进制数字简单:

Enter hex number simple:

cin >> hex >> x;


推荐答案

可以使用 std :: dec IO操纵器

std::cout << std::dec << int(x) << endl;

注意,这只有在您以前使用过 std :: hex 或其他方法来操纵 std :: cout 的基础。否则你需要不采取行动: int 的默认值是十进制。

Note that this is only necessary if you have previously used std::hex or other means to manipulate the base of std::cout. Otherwise you need take no action: the default for an int is decimal.

这篇关于将hex转换为dec C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆