Hi all,
I am wondering if C has an equivalent of Java's isNumeric method. I want users to be able to enter a range of IP addresses, like 10.1.1.5-15. I use sscanf( ip, "%d.%d.%d.%d", octet1, octet2, octet3, octet4 ) at the present to parse the octets into separate ints. However, I would like to allow the users to enter a range, and would use something like:
Code:
sscanf( ip, "%d.%d.%d.%s", octet1, octet2, octet3, strOctet4 );
if( isnumeric( strOctet4 )) {
sscanf( strOctet4, "%d", octet4 );
}
else {
/* use something like strtok() to break
strOctet4 into two ints representing a
lower and upper range.
*/
}
If there is no C function similar to isNumeric, what would you recommend? Checking the ASCII value of each char in strOctet4 to see if it falls in the range of a number?
Once again, thanks in advance!