将字符串转换为无符号长整型。
string str = "0x1232"
如何转换为无符号长整型。
这是我尝试过的方法。
unsigned long long ull;
ull = stoull(str, NULL, 0);
错误:
error: identifier "stoull" is undefined
ull = stoull(str, NULL, 0);
你能给我一些提示吗?
将字符串转换为无符号长整型。
string str = "0x1232"
如何转换为无符号长整型。
这是我尝试过的方法。
unsigned long long ull;
ull = stoull(str, NULL, 0);
错误:
error: identifier "stoull" is undefined
ull = stoull(str, NULL, 0);
你能给我一些提示吗?
首先是 strtoull
(注意其中的字母 r
),其次,它是一个旧的 C 风格函数,不能直接处理 std::string
。你需要传递给它 str.c_str()
或使用新的 std::stoull
。
ull = std::strtoull(str.c_str(), 0, 16);
。 - Some programmer dude