In C programming, what standard library header provides functions for character classification?

The story behind the answer

In C programming, the standard library header that provides character-classification functions is `<ctype.h>`.

Including `<ctype.h>` makes the declarations and macros for operations such as `isalpha`, `isdigit`, `isspace`, `islower`, `isupper`, `ispunct`, `tolower`, and `toupper` available. These routines classify or transform individual characters according to the program’s active locale, rather than assuming that every execution environment uses exactly the same character set.

The header is distinct from the other options. `<stdio.h>` declares stream and formatted-input/output facilities such as `printf`; `<stdlib.h>` covers utilities including memory allocation and numeric conversion; and `<string.h>` supplies operations on null-terminated byte strings and memory blocks. Character classification belongs in `<ctype.h>` even when the result is later used while processing a string.

A subtle C detail is that the `is...` macros expect either `EOF` or a value representable as `unsigned char`. Passing a negative plain `char` value can cause undefined behavior on implementations where `char` is signed. For wide-character classification, C uses the related `<wctype.h>` header and functions such as `iswalpha`.

Source: Wikipedia · fact-checked Sept. 2026

Add question to a list

Choose a list to keep this question in: