determines whether the string is a numeric string

www.l‮c.iruttua‬om
determines whether the string is a numeric string

check whether the string is numerical

int isNumber(char s[])
{
    for (int i = 0; s[i]!= '\0'; i++)
    {
		if(i==0 ){
			if(s[i]!= '-' && isdigit(s[i]) == 0) // 不是负数,也不是数字
				return 0;
		}
        else if (isdigit(s[i]) == 0)
              return 0;
    }
    return 1;
}
Created Time:2017-08-28 11:49:47  Author:lautturi