liveBook · Manning

Ctype.h

As explained in Modern C

ctype.h is the C standard header declaring character classification and character-case conversion functions and macros.

Include <ctype.h> when character classes matter more than a particular encoding. Its classifiers—such as isalpha, isdigit, isspace, isalnum, and isxdigit—test characters, while toupper and tolower convert alphabetic case. For historical reasons, these interfaces accept and return int, not char. section 8.4

Classify, normalize, then convert

A base-36 digit converter can first test isdigit(a), subtract '0' for decimal digits, then apply toupper(a) and use isupper(a) before subtracting 'A'. toupper leaves nonalphabetic characters unchanged. The implementation relies on consecutive decimal digits and uppercase or lowercase letters, so it explicitly checks the relevant assumptions.

How Modern C covers it

How deep it goes
Defines the classifier families and demonstrates their composition, but defers a complete interface specification.
Examples
Uses a base-36 digit converter and a table of classifier meanings, including C-locale and extended-character cases.
What it assumes
Assumes basic C expressions and character constants while explaining integer character-constant types and encoding assumptions.
What you can do after
Apply it via ctype.h to classify characters and normalize alphabetic case during parsing or conversion.
How it connects
Connects character classification with character constants, string literals, locales, and numerical conversion.

Also explained in

Compare how 2 books explain ctype.h →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.