提供API时我有一个问题
如果我要求他们给我一个_int6410位十六进制数字,但我的函数内部采用字符串如何有效地转换...
截至目前我只是在内部使用字符串,但出于兼容性原因,我使用的是char*c样式,因此任何系统32或64都无关紧要.这是准确的事情吗?或者我错了?
使用char*vs 有问题_int64吗?
#include <string>
#include <sstream>
int main()
{
std::stringstream stream;
__int64 value(1000000000);
stream << value;
std::string strValue(stream.str());
return 0;
}
Run Code Online (Sandbox Code Playgroud)
C ++ 11标准化了std::to_string功能:
#include <string>
int main()
{
int64_t value = 128;
std::string asString = std::to_string(value);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21522 次 |
| 最近记录: |