参考stackoverflow: converting _int64 to a string,验证建议的代码可以成功地将_int64转换到string。
C++ 11的标准做法:
#include <string>
int main()
{
int64_t value = 100;
std::string asString = std::to_string(value);
return 0;
}
使用stringstream
:
#include <string>
#include <sstream>
int main()
{
std::stringstream stream;
__int64 value(1000000000);
stream << value;
std::string strValue(stream.str());
return 0;
}
使用C sprintf()
或者 _i64toa()
__int64 value = ...;
char buffer[20];
sprintf(buffer, "%Ld", value);
__int64 value = ...;
char buffer[20];
_i64toa(value, buffer, 10);
参考
stackoverflow: converting _int64 to a string
Microsoft Docs: _itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow