【发布时间】:2019-02-26 17:20:08
【问题描述】:
我需要将文本文件中数字输入的(十进制,如果重要的话)字符串表示形式转换为 UINT64 以传递给我的数据对象。
size_t startpos = num.find_first_not_of(" ");
size_t endpos = num.find_last_not_of(" ");
num = num.substr(startpos, endpos-startpos+1);
UINT64 input;
//convert num to input required here
有没有办法以类似于 atoi() 的方式将 std::string 转换为 UINT64?
谢谢!
编辑: 工作代码如下。
size_t startpos = num.find_first_not_of(" ");
size_t endpos = num.find_last_not_of(" ");
num = num.substr(startpos, endpos-startpos+1);
UINT64 input; //= std::strtoull(num.cstr(), NULL, 0);
std::istringstream stream (num);
stream >> input;
【问题讨论】:
-
在 uint64 中保存小数?
-
这是一个我正在使用现有结构的项目。在我的例子中,这只是对象的结构。