Standard C Libraries -. More...
Go to the source code of this file.
Functions | |
int | isalnum (int c) |
int | isalpha (int c) |
int | iscntrl (int c) |
int | isdigit (int c) |
int | isgraph (int c) |
int | islower (int c) |
int | isprint (int c) |
int | ispunct (int c) |
int | isspace (int c) |
int | isupper (int c) |
int | isxdigit (int c) |
int | tolower (int c) |
int | toupper (int c) |
Standard C Libraries -.
The header file, ctype.h, consists of functions that are useful for classifying and mapping characters. Characters are interpreted according to the Standard C locale.
The documentation in this header file has been copied from the documentation provided with the Microchip MPLAB XC16 compiler. The original license agreement included with the XC16 compiler applies!
int isalnum | ( | int | c) |
Description: Test for an alphanumeric character.
Include: <ctype.h>
c | The character to test. |
Remarks:
Alphanumeric characters are included within the ranges A-Z, a-z or 0-9.
Example:
Output:
3 is an alphanumeric
# is NOT an alphanumeric
int isalpha | ( | int | c) |
Description: Test for an alphabetic character.
Include: <ctype.h>
c | The character to test. |
Remarks:
Alphabetic characters are included within the ranges A-Z or a-z.
Example:
Output:
B is alphabetic
# is NOT alphabetic
int iscntrl | ( | int | c) |
Description: Test for a control character.
Include: <ctype.h>
c | character to test. |
Remarks:
A character is considered to be a control character if its ASCII value is in the range, 0x00 to 0x1F inclusive, or 0x7F.
Example:
Output:
B is NOT a control character
A tab is a control character
int isdigit | ( | int | c) |
Description: Test for a decimal digit.
Include: <ctype.h>
c | character to test. |
Remarks:
A character is considered to be a digit character if it is in the range of ‘0'- ‘9'.
Example:
Output:
3 is a digit
# is NOT a digit
int isgraph | ( | int | c) |
Description: Test for a graphical character.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a graphical character if it is any printable character except a space.
Example:
Output:
3 is a graphical character
# is a graphical character
a space is NOT a graphical character
int islower | ( | int | c) |
Description: Test for a lower case alphabetic character.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a lower case alphabetic character if it is in the range of ‘a'-‘z'.
Example:
Output:
B is NOT lower case
b is lower case
int isprint | ( | int | c) |
Description: Test for a printable character (includes a space).
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a printable character if it is in the range, 0x20 to 0x7e inclusive.
Example:
Output:
& is a printable character
a tab is NOT a printable character
int ispunct | ( | int | c) |
Description: Test for a punctuation character.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a punctuation character if it is a printable character which is neither a space nor an alphanumeric character. Punctuation characters consist of the following:
Example:
Output:
& is a punctuation character
a tab is NOT a punctuation character
int isspace | ( | int | c) |
Description: Test for a white-space character.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a white-space character if it is one of the following:
Example:
Output:
& is NOT a white-space character
a tab is a white-space character
int isupper | ( | int | c) |
Description: Test for an upper case letter.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be an upper case alphabetic character if it is in the range of ‘A'-‘Z'.
Example:
Output:
B is upper case
b is NOT upper case
int isxdigit | ( | int | c) |
Description: Test for a hexadecimal digit.
Include: <ctype.h>
c | character to test |
Remarks:
A character is considered to be a hexadecimal digit character if it is in the range of ‘0'-‘9', ‘A'-‘F', or ‘a'-‘f'. Note: The list does not include the leading 0x because 0x is the prefix for a hexadecimal number but is not an actual hexadecimal digit.
Example:
Output:
B is a hexadecimal digit
t is NOT a hexadecimal digit
int tolower | ( | int | c) |
Description: Convert a character to a lower case alphabetical character.
Include: <ctype.h>
c | The character to convert to lower case. |
Remarks:
Only upper case alphabetical characters may be converted to lower case.
Example:
Output:
B changes to lower case b
b remains lower case b
@ has no lower case, so @ is returned
int toupper | ( | int | c) |
Description: Convert a character to an upper case alphabetical character.
Include: <ctype.h>
c | The character to convert to upper case. |
Remarks:
Only lower case alphabetical characters may be converted to upper case.
Example:
Output:
b changes to upper case B
B remains upper case B
@ has no upper case, so @ is returned