void isInt(char *string)
{
if (strlen(string) > 2)
printf("Invalid")
if (!strtol(string, &endptr, 10))
printf("Invalid")
printf("Valid")
}
i have this code which checks if a series of 1 or 2 characters contain only integers for example 12, 1, 10 would be valid but 6g, ii would not be valid. The problem i have is that if the input string contains a 0 then it returns invalid for example 0 or 10 should be valid but are not. How would i let 0 be valid? or is there just an overall easier way to do this?
Would you please try:
Output: