In C++. What are the alternatives to Integer.parseInt() and String.valueOf() of Java in C++.
Asked
Active
Viewed 1.7k times
3 Answers
8
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

Mohit Jain
- 30,259
- 8
- 73
- 100
0
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.

Juned Ahsan
- 67,789
- 12
- 98
- 136