liveBook · Manning

Tolower

As explained in Modern C

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

#include <ctype.h> int c = tolower('A'); `tolower` converts an uppercase alphabetic character to its corresponding lowercase character. It leaves other characters unchanged. The interface accepts an `int` and returns an `int`, reflecting the type of C integer character constants. section 8.4

TAKEAWAY

  • Include <ctype.h> to use the character-conversion interface. section 8.4
  • Expect alphabetic characters to change case and all other characters to remain unchanged. section 8.4
  • Treat the argument and result as int rather than char; this follows C's historical character-constant conventions. section 8.4
Table 8.11. Character classifiers The third column indicates whether C implementations may extend these classes with platform-specific characters, such as 'ä' as a lowercase character or '€' as punctuation. (view table figure)

Name

Meaning

C locale

Extended

islower Lowercase 'a' ... 'z' Yes
isupper Uppercase 'A' ... 'Z' Yes
isblank Blank ' ', '\t' Yes
isspace Space ' ', '\f', '\n', '\r', '\t', '\v' Yes
isdigit Decimal '0' ... '9' No
isxdigit Hexadecimal '0' ... '9', 'a' ... 'f', 'A' ... 'F' No
iscntrl Control '\a', '\b', '\f', '\n', '\r', '\t', '\v' Yes
isalnum Alphanumeric isalpha(x)||isdigit(x) Yes
isalpha Alphabet islower(x)||isupper(x) Yes
isgraph Graphical (!iscntrl(x)) && (x != ' ') Yes
isprint Printable !iscntrl(x) Yes
ispunct Punctuation isprint(x)&&!(isalnum(x)||isspace(x)) Yes

The character-classifier table situates tolower beside islower, isupper, and related ctype.h interfaces, including their platform-specific extensions. section 8.4

How Modern C covers it

How deep it goes
Defines the header, argument and return types, conversion behavior, and unchanged-character rule without developing implementation internals.
Examples
Uses the expression tolower('A') and contrasts alphabetic conversion with unchanged nonalphabetic characters.
What it assumes
Assumes basic C character constants while teaching their int type and the ctype.h interface.
What you can do after
Apply it via the C library to convert alphabetic character values to lowercase.
How it connects
Connects to ctype.h, toupper, character classifiers, character constants, and string processing.

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.