方法一
#include <string>
int hexToDec(const std::string& hexString)
{
return std::stoi(hexString, nullptr, 16);
}
方法二
#include <ios>
int hexToDec(std::string hexString)
{
int n;
std::istringstream(hexString) >> std::hex >> n;
return n;
}
方法三
int hexToDec(std::string hexString)
{
return (int)strtol(hexString.c_str(), 0, 16);
}
方法四
int hexToDec(std::string hex) {
int decValue;
sscanf(hex.c_str(), "%x", &decValue);
return decValue;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)