The character classification and conversion routines allow you to test individual characters in a variety of ways and to convert between uppercase and lowercase characters.
Routine | Use |
isalnum | Tests for alphanumeric character |
isalpha | Tests for alphabetic character |
__isascii | Tests for ASCII character |
iscntrl | Tests for control character |
__iscsym | Tests for letter, underscore, or digit |
__iscsymf | Tests for letter or underscore |
isdigit | Tests for decimal digit |
isgraph | Tests for printable character except space |
islower | Tests for lowercase character |
isprint | Tests for printable character |
ispunct | Tests for punctuation character |
isspace | Tests for white-space character |
isupper | Tests for uppercase character |
isxdigit | Tests for hexadecimal digit |
__toascii | Converts character to ASCII code |
tolower | Tests character and converts to lowercase if uppercase |
_tolower | Converts character to lowercase (unconditional) |
toupper | Tests character and converts to uppercase if lowercase |
_toupper | Converts character to uppercase (unconditional) |
The classification routines identify characters by finding them in a table of classification codes. Using these routines to classify characters is generally faster than writing a test expression such as the following:
if ((c >= 0) || (c <= 0x7f))
All of these routines are implemented in two versions: as functions and as macros. The function prototypes and macro definitions appear in CTYPE.H. “Choosing Between Functions and Macros” explains how to choose the appropriate version. The toupper and tolower functions are also declared in the STDLIB.H header file.