This section explains the library functions for classifying characters.
isalpha is the function to test for an alphabetic
character. It takes one argument, the character to test, and returns a
nonzero integer if the character is alphabetic, and zero otherwise. You
would use it like this:
if (isalpha (c)) printf ("The character `%c' is alphabetic.\n", c);
Each of the functions in this section tests for membership in a
particular class of characters; each has a name starting with ‘is’.
Each of them takes one argument, which is a character to test, and
int which is treated as a boolean value. The
character argument is passed as an
int, and it may be the
EOF instead of a real character.
The attributes of any given character can vary between locales. See Locales, for more information on locales.
These functions are declared in the header file ctype.h.
Returns true if c is a lower-case letter. The letter need not be from the Latin alphabet, any alphabet representable is valid.
Returns true if c is an upper-case letter. The letter need not be from the Latin alphabet, any alphabet representable is valid.
Returns true if c is an alphabetic character (a letter). If
isupperis true of a character, then
isalphais also true.
In some locales, there may be additional characters for which
isalphais true—letters which are neither upper case nor lower case. But in the standard
"C"locale, there are no such additional characters.
Returns true if c is an alphanumeric character (a letter or number); in other words, if either
isdigitis true of a character, then
isalnumis also true.
Returns true if c is a hexadecimal digit. Hexadecimal digits include the normal decimal digits ‘0’ through ‘9’ and the letters ‘A’ through ‘F’ and ‘a’ through ‘f’.
Returns true if c is a punctuation character. This means any printing character that is not alphanumeric or a space character.
Returns true if c is a whitespace character. In the standard
isspacereturns true for only the standard whitespace characters:
- carriage return
- horizontal tab
- vertical tab
Returns true if c is a blank character; that is, a space or a tab. This function was originally a GNU extension, but was added in ISO C99.
Returns true if c is a graphic character; that is, a character that has a glyph associated with it. The whitespace characters are not considered graphic.
Returns true if c is a printing character. Printing characters include all the graphic characters, plus the space (‘ ’) character.
Returns true if c is a control character (that is, a character that is not a printing character).