Aaand you still dont get it.
isdigit() compares element in char array with all 10 digits, and digits are I repeat, 1 2 3 4 5 6 7 8 9 0, if it matches at least one of those characters, it will return true, else it returns false. Learn a difference between DIGIT (read: character) and number (mathematical object which represents count)
Consider this fragment:
1 2 3 4 5
|
int main()
{
int a = 75;
if(isdigit(a)) cout << "Integer is a digit." << endl;
}
|
Program will NOT output "Integer is a digit." beacuse it does NOT respond to int, or double or float, but only checks if an element in CHAR array is a DIGIT.
Also consider this fragment:
1 2 3 4 5
|
int main()
{
char a[50] = "185asd";
if(isdigit(a[0])) cout << a[0] << " is a digit." << endl;
}
|
Element 0 in array a is "1", and its a digit, therfore it returns true.
Also your book should have told you that cctype... (let me quote)
declares a set of functions to classify and transform individual characters.
All these functions take as parameter the int equivalent of one character and return an int, that can either be another character or a value representing a boolean value: an int value of 0 means false, and an int value different from 0 represents true.
|
and the link I provided you says...
int isdigit ( int c );
Checks if parameter c is a decimal digit character.
|
EDIT: Also I repeat, your question did not make any sense. It is in many ways completly useless to check if double is a digit.