Using ctype.h
The ctype.h library has functions for classifying characters. Each of the functions below returns an int when passed in a char.- isalnum() Check if character is alphanumeric (isalpha) | isdigit()
- isalpha() - Check if character is alphabetic
- iscntrl() - Check if character is a control character
- isdigit() - Check if character is decimal digit
- isgraph() - Check if character has graphical representation
- islower() - Check if character is lowercase letter
- isprint() - Check if character is printable
- ispunct() - Check if character is a punctuation character
- isspace() - Check if character is a white-space
- isupper() - Check if character is uppercase letter
- isxdigit() - Check if character is hexadecimal digit
There are a couple of ancillary functions for converting upper case letter to lower case etc.
- tolower() - Converts upper case letter to lower case
- toupper() - Converts lower case letter to upper case
This example calls most of the functions except upper and lower case for each value in the range 0 to 127. You can see for example how isalnum() is just isalpha() binary ored with isdigit().
On the next page : Using the str functions

