我将使用以下代码将
Const char *
转换为 Unsigned long int
,但输出结果始终为 0
。我做错了什么?请告诉我。
这是我的代码:
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;
int main()
{
vector<string> tok;
tok.push_back("2");
const char *n = tok[0].c_str();
unsigned long int nc;
char *pEnd;
nc=strtoul(n,&pEnd,1);
//cout<<n<<endl;
cout<<nc<<endl; // it must output 2 !?
return 0;
}
std::stoull
,而“unsigned long”则是std::stoul
。 - Volomike