2013年5月8日 星期三

判斷string是否為number

bool IsNumber(const std::wstring& str)
{
   if ( str.empty() )
      return false;
  
   int pos = 0;
  
   if ( str[0] == _T('-') && str.length() >= 2)
      pos = 1;
   return (str[pos] >= _T('0') && str[pos] <= _T('9'));
}

沒有留言:

張貼留言