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.
Like this:
int StringToInt( const std::string & str )
{
std::stringstream ss(str);
int res = 0;
ss >> res;
return res
}
精彩评论