0

In C++, what is the best way to take input string and convert it to a number type. I was messing around with literal strings and was having a difficult time doing this, I am imagining that using a C String is easier? What is the best way for co-workers and fellow students to follow and make it easy and simple? Any thoughts?

What is the industry standard on this? Using STOI?

Sam Arnold
  • 45
  • 1
  • 1
  • 10

1 Answers1

0

Look at the following example:

std::string numberString = "125";
int number = std::stoi(numberString ,nullptr);

It can convert an std::string to int

Emil Rowland
  • 538
  • 5
  • 25