我想将整数转换为字符串。我以这种方式尝试过,但这没有用
void foo()
{
int y = 1;
string x = static_cast<string>(y);
}
该std::to_string
功能应该做到这一点:
string x = std::to_string(y);
相反,它是std::stoi
:
int z = std::stoi(y, nullptr, 10);
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句