isdigit()

Prototype: int isdigit(int Character);
Header File: ctype.h (C) or cctype (C++)
Explanation: This function accepts an ASCII value, and returns whether or not it is a digit (0 to 9) when converted to its equivalent ASCII character. It returns a zero if it is not a digit, and non-zero if it is.




Example:
//Example reads in a character and checks to see if it is a digit
#include <cctype>
#include <iostream>

using namespace std;

int main()
{
    char a_char;
    cin>>a_char;
    if(isdigit(a_char))
    {
        cout<<"Is a digit!";
    }
    else
    {
        cout<<"Is not a digit!";
    }
}
Other Functions