C++ Notes: Character functions - <cctype>

Character functions - <cctype>

Here are some of the most common functions to with single characters. The types of the parameters are c=char/int. Some parameters have the const attribute, but it's not indicated below.

Because these are the original C functions, bool isn't used. Instead, zero is false and non-zero is true.

TypeMethodDescription
#include <cctype> (or older <ctype.h>)
intisalnum(c) true if c is a letter or digit.
intisalpha(c) true if c is a letter.
intisblank(c) true if c is a blank or tab.
intisdigit(c) true if c is a digit.
intislower(c) true if c is a lowercase letter.
intisupper(c) true if c is an uppercase letter.
intisspace(c) true if c is whitespace character (space, tab, vertical tab, formfeed, carriage return, or newline).
inttolower(c) returns lowercase version of c if there is one, otherwise it returns the character unchanged.
inttoupper(c) returns uppercase version of c if there is one, otherwise it returns the character unchanged.