将字符串转换为unsigned long long。
string str = "0x1232"
我如何转换成无符号的long long。
这就是我尝试过的。
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
。