C++ Character functions
Tags:
cpp
stl
Following functions are a part of the <cctype>
header file
Checking character class
Note: true
is 1
and false
is 0
in these functions
isalpha(char c)
: Returns true ifc
is a-z or A-Zisupper(char c)
: Returns true ifc
is A-Z i.e. UPPERCASEislower(char c)
: Returns true ifc
is A-Z i.e. lowercaseisdigit(char c)
: Returns true ifc
is 0-9isxdigit(char c)
: Returns true ifc
is hexadecimal digit (0-9 or a-f)isalnum(char c)
: Returns true ifc
is alphanumeric (a-z or A-Z or 0-9)isblank(char c)
: Returns true ifc
is a space or tabispunct(char c)
: Returns true ifc
is a punctuation markisprint(char c)
: Returns true ifc
is printable on console
Changing case
tolower(char c)
- returns lowercase equivalent of input character.toupper(char c)
- returns UPPERCASE equivalent of input character.
Code to print ALL punctuation characters:
Output: