c++ - How to convert an integer to a string -
this question has answer here:
- easiest way convert int string in c++ 20 answers
i want convert integer string. tried way didn't work
void foo() { int y = 1; string x = static_cast<string>(y); }
the std::to_string
function should it:
string x = std::to_string(y);
for opposite, it's std::stoi
:
int z = std::stoi(y, nullptr, 10);
Comments
Post a Comment