3

In C++. What are the alternatives to Integer.parseInt() and String.valueOf() of Java in C++.

2

3 Answers 3

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:
stoi and tostring
istringstream and ostringstream
atoi and sprintf

Sign up to request clarification or add additional context in comments.

Comments

1

I would prefer to use sstream.

Comments

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.

Reference: http://www.cplusplus.com/reference/cstdlib/atoi/

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.