In C++. What are the alternatives to Integer.parseInt() and String.valueOf() of Java in C++.
3 Answers
For Integer.parseInt you can use std::stoi, std::istringstream, sscanf, atoi etc.
For String.valueOf() alternatives, you can std::ostringstream, sprintf, std::tostring etc.
Recommendations:
c++11 stoi and tostring
c++ istringstream and ostringstream
c atoi and sprintf
Comments
You may use atoi c++ function.
int atoi (const char * str); Convert string to integer Parses the C-string str interpreting its content as an integral number, which is returned as a value of type int.
std::stoiandstd::to_string.