0

Possible Duplicates:
How to convert a number to string and vice versa in C++
c++ - convert pointer string to integer

Is there a way to convert a string into an integer parameter without any big algorithms?

string = "100";

integerFunction(int string);

I've tried atoi functions and tried to manually convert each number over with the string[count] - 48 way but it needs to be in a way where the number of digits don't become a problem with this. Any suggestions or algorithms out there that can help? I really appreciate it.

Community
  • 1
  • 1
Jason A.
  • 71
  • 1
  • 6

1 Answers1

0

Like this:

int StringToInt( const std::string & str )
{
  std::stringstream ss(str);
  int res = 0;
  ss >> res;
  return res
}
BЈовић
  • 62,405
  • 41
  • 173
  • 273