bool Is_Number( constchar &Value )
{
return( ( Value >= '0' ) && ( Value <= '9' ) );
}
This code takes a character as an argument. It then evaluates the value of Value. If Value is between the ASCII character equivalent of 0 (zero) and 9, the function returns true; false otherwise. You can invoke this function like this:
1 2 3 4 5 6
char String[7] = "Wa22ak";
if( Is_Number( String[2] ) )
std::cout << "Is a number\n";
else std::cout << "Isn't a number\n";