字符串转整型

由字符串转为int型…

int strToInt(const char c)
{
if(c == NULL)
throw “NULL point..”;
int sum = 0;
int n = 10;
int flag = 1;
while(
c)
{
if(c == ‘ ‘||c == ‘+’)
{
c++;
continue;
}
if(*c == ‘-‘)
{
flag = -1;
c++;
continue;

}
sum = n;
sum +=
c-‘0’;
c++;
}
return sum*flag;
}

  • 本文作者: 帐前卒
  • 本文链接: http://chillyc.info/2007/1564837/
  • 版权声明: 本博客所有文章除特别声明外,只能复制超链接地址,且必须注明出处!