isalnum()

Prototype: int isalnum(int ch);
Header File: ctype.h (C) cctype (C++)
Explanation: Isalnum does exactly what is sounds like, checks if the ASCII value passed in has a character equivalent to a number of letter. It returns non-zero for true, and zero for false.



//Example reads in a character and checks if it is alpha-numeric
#include <iostream>
#include <cctype>

using namespace std;

int main()
{
    char x;
    cin>>x;
    if(isalnum(x))
    {
        cout<<"It's alpha-numeric";
    }
    else
    {
        cout<<"It's not alpha-numeric;  
    }
}
Other Functions