In this video, we'll talk about the functions that
we can use with characters.
This cctype library includes very simple and very useful functions
that allow the testing of characters for various properties as well as
the conversion of characters from upper to lower or lower to uppercase.
In order to use these functions, you must include cctype.
The functions all expect a single character.
In the case of the testing functions, they evaluate to true or false.
And the conversion functions return the converted character.
Let's see some of these functions.
This table contains some of the functions in cctype that
allow for testing of characters.
You call the function and pass into character you wish
to test in the parentheses.
The function that evaluates to true or false depending on
whether the character has the property your testing or not.
Isalpha test to see if a character is a letter, either uppercase or
lowercase and evaluates to true if it is or false otherwise.
Isalnum test to see if the character is a letter or digit.
Isdigit test to see if the character is a digit.
Islower test to see if the character is a lowercase letter.
Isprint test to see if the character is a printable character.
Ispunct test to see if the characters of punctuation character.
Isupper test to see if the characters and uppercase letter.
And isspace test to see if the characters of whitespace character.
There are a few other functions in cctype that I
haven't listed in the table.
You can refer to the c++ docs for those.
Now let's see the conversion functions.
The two character conversion functions are tolower and toupper.
Tolower evaluates the lower case equivalent of the character passed in
and toupper the uppercase equivalent.
If these functions can't perform the conversion, then a
function simply evaluate to the character that was passed in.
As you can see, these functions are very handy.
They're also extremely efficient.
We'll use these functions in the next few videos when
we talk more about strings.
In the next video, we'll learn about c style strings.
I'll see you there.