#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
