liveBook · Manning

Toupper

As explained in Modern C

toupper is a C character-case conversion function or macro that converts a lowercase alphabetic character to its corresponding uppercase character.

Include <ctype.h> to use toupper, which converts an alphabetic character to the corresponding case and leaves every other character unchanged. It accepts and returns int, reflecting C's treatment of integer character constants such as 'a'. section 8.4

Normalizing a hexadecimal digit

unsigned hexatridecimal(int a) { if (isdigit(a)) return a - '0'; a = toupper(a); return (isupper(a)) ? 10 + (a - 'A') : -1; } Here toupper makes lowercase alphabetic digits comparable with uppercase digits; non-Latin-uppercase results are rejected by the following test.

How Modern C covers it

How deep it goes
Defines conversion behavior and argument types, then demonstrates one integrated use; it does not descend into implementation internals.
Examples
Uses hexadecimal-digit conversion to show toupper before uppercase classification and numeric mapping.
What it assumes
Assumes basic C expressions and character constants while clarifying that character constants have type int.
What you can do after
Apply toupper through <ctype.h> to normalize alphabetic characters while preserving nonalphabetic input.
How it connects
Connects toupper with <ctype.h>, isdigit, isupper, islower, tolower, character constants, and locale-dependent character classes.

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.