Cctype header file contains functions are mainly used to test the character value, the following is a random look for a table, but for beginners, how to use it, their own on the machine operation to solve, the latter two returned to the int type, indeed very unexpected, forced conversion, very simple.
Isalnum (c) True if C is a letter or a number
Isalpah (c) True if C is a letter
Iscntrl (c) True if C is a control character
IsDigit (c) True if C is a number
Isgraph (c) True if C is not a space
Islower (c) True if C is a lowercase letter
Isprint (c) True if C is a printable character
Ispunct (c) True if C is a punctuation mark
Isspace (c) True if C is a blank character
Isupper (c) True if C is a capital letter
Isxdigit (c) True if C is a hexadecimal number
ToLower (c) If C is a capital letter, it returns a lowercase letter, otherwise it returns C.
ToUpper (c) If C is a lowercase letter, return a larger letter form, otherwise return C.
I demonstrate the first and last, more representative.
#include <iostream> #include <cctype> using namespace std; int main () {char C; C= ' d '; if (Isalnum (c)) {cout "C" "is a alpha or number"; else cout "C" "is a not alpha or number"; The output results are shown below: #include <iostream> #include <cctype> using namespace std; int main () {char C; c= ' D '; cout Char (ToLower (c));
The ToLower () function returns an integer type, so if you do not overload the function, the correct output is achieved by type conversion, so watch out.