C++判断是否是纯数字
bool isDigitStr(const char* cstr)
{
if (NULL == cstr || cstr[0] == 0)
{
return false;
}
int len = strlen(cstr);
int pos = 0;
if (cstr[0] == '-' || cstr[0] == '+')
{
if (len <= 1)
{
return false;
}
pos++;
}
while (pos < len)
{
if (cstr[pos] < '0' || cstr[pos] > '9')
{
return false;
}
pos++;
}
return true;
}