开发者

Converting a string into an integer parameter [duplicate]

This question already has answers here: Closed 11 years ago.

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜