C++ 将字符串转换为c+中的无符号长字符串+;
将字符串转换为无符号长字符串C++ 将字符串转换为c+中的无符号长字符串+;,c++,casting,type-conversion,C++,Casting,Type Conversion,将字符串转换为无符号长字符串 string str = "0x1232" 如何转换为无符号long 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"
如何转换为无符号long
string str = "0x1232"
这就是我尝试过的
unsigned long long ull;
ull = stoull(str, NULL, 0);
错误:
error: identifier "stoull" is undefined
ull = stoull(str, NULL, 0);
你能给我一些建议吗?首先,请注意
r
。其次,它是一个旧的C风格函数,不能直接处理std::string
。你要么通过它,要么使用新的。你能举个例子吗?@pistal,这里有一个std::stoi的例子,非常接近std::stoull(str,NULL,16)@pistal那么你的编译器太旧了,没有C++11std::stoull
。您必须使用strtoull
,但相应地更改参数。@pistal是的,这是正确的。例如,ull=std::strtoull(str.c_str(),0,16)代码>