Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将字符串转换为c+中的无符号长字符串+;_C++_Casting_Type Conversion - Fatal编程技术网

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++11
std::stoull
。您必须使用
strtoull
,但相应地更改参数。@pistal是的,这是正确的。例如,
ull=std::strtoull(str.c_str(),0,16)