C Character Class Test Library

A Little C Primer · Wikibooks

0%

Contents

    Text

    Size
    100%
    Theme
    Typeface
    Line length
    Spacing

    Read aloud

    How

    Speed: 1×
    Light up
    Highlight

    Symbols: Mulberry Symbols, © 2018–2026 Steve Lee, CC BY-SA 4.0 (licence, the set), the site's own copies.

    From Wikibooks, under CC BY-SA 4.0, as the source states it. This page at Wikibooks.

    C Character Class Test Library

    These functions perform various tests on characters. They require the declaration:

       #include <ctype.h>
    

    The character is represented as an "int" and the functions return an "int". They return 0 if the test is false and non-0 if the test is true:

       isalnum( c )     Character is alpha or digit.
       isalpha( c )     Character is alpha.
       iscntrl( c )     Character is control character.
       isdigit( c )     Character is decimal digit.
       isgraph( c )     Character is printing character (except space).
       islower( c )     Character is lower-case.
       isprint( c )     Character is printing character (including space).
       ispunct( c )     Character is printing character but not space/alpha-digit.
       isspace( c )     Character is space, FF, LF, CR, HT, VT.
       isupper( c )     Character is upper-case.
       isxdigit( c )    Character is hex digit.
    

    The library also contains two conversion functions that also accept and return an "int":

       tolower( c )    Convert to lower case.
       toupper( c )    Convert to upper case.