// Correct number format for a signed integer
// is given by regex [-+]+[0-9]*
// '0' to '9' must be continuous in C and C++
// str must be \0-terminated
bool is_a_number( const char* str )
{
if( *str=='-' || *str=='+' ) ++str;
while (*str >= '0' && *str<='9')
++str;
// return true if the first nondigit is the end.
return (*str=='\0');
}
// Using std::string::c_str() is less efficient
bool is_a_number ( std::string const& str )
{
std::string::iterator si = str.begin();
const std::string::iterator end = str.end();
if( *si=='-' || *si=='+' ) ++si;
while ( si != end && (*si>='0' && *si <='9') )
++si;
// return true if the first nondigit is the end.
return ( si == end );
}
//For wchar_t, substitute L'0' for '0' etc.