In C++. What are the alternatives to Integer.parseInt() and String.valueOf() of Java in C++.
Asked
Active
Viewed 1.6k 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
- 29,859
- 8
- 70
- 95
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
- 66,028
- 11
- 91
- 129