The header <ctype.h> declares several functions useful for testing and mapping characters. In all cases the argument is an int, the value of which shall be representable as an unsigned char or shall be equal to the value of the macro EOF. If the argument has any other value, the behavior is undefined.
The behavior of these functions is effected by the current locale[1]. Those functions that have implementation-defined aspects only when not in the "C" locale are noted below.
The term printing character refers to a member of an implementation-defined set of characters, each of which occupies one printing position on a display device: the term control character refers to a member of an implementation-defined set of characters that are not printing characters.
All the character testing functions are defined as macros that test one or more bits in a constant array indexed by the given character, which must be in the range -1 to 255.
On the ERC32, the size of the array is 257 bytes.
On the M1750, the size of the array is 257, 16-bit words, (a total of 514 bytes).
#include <ctype.h>
int
isalnum
(int c
);
The isalnum function tests for any character for which isalpha or isdigit is true.
#include <ctype.h>
int
isalpha
(int c
);
The isalpha function tests for any character for which isupper or islower is true, or any character that is one of an implementation-defined set of characters for which non of iscntrl, isdigit, ispunct, or isspace is true. In the "C" locale, isalpha returns true for only the characters for which isupper or islower is true.
#include <ctype.h>
int
iscntrl
(int c
);
The iscntrl function tests for any control character.
#include <ctype.h>
int
isdigit
(int c
);
The isdigit function tests for any decimal-digit character (as defined in ANSI C section 5.2.1).
#include <ctype.h>
int
isgraph
(int c
);
The isgraph function tests for any printing character except space (' ').
#include <ctype.h>
int
islower
(int c
);
The islower function tests for any character that is an lowercase letter or is one of an implementation-defined set of characters for which none of iscntrl, isdigit, ispunct or isspace is true. In the "C" locale, islower returns true only for the characters defined as lower case letters (as defined in ANSI C section 5.2.1).
#include <ctype.h>
int
isprint
(int c
);
The isprint function tests for any of the printing characters including space (' ').
#include <ctype.h>
int
ispunct
(int c
);
The ispunct function tests for any printing character that is neither a space (' ') nor a character for which isalnum is true.
#include <ctype.h>
int
isspace
(int c
);
The isspace function tests for any character that is a standard white space character or is one of an implementation-defined set of characters for which isalnum is false. The standard white space characters are the following: space (' '), form feed ('\f'), new_line ('\n'), carriage return ('\r'), horizontal tab ('\t'), and vertical tab ('\v'). In the "C" locale, isspace returns true only for standard white space characters.
#include <ctype.h>
int
isupper
(int c
);
The isupper function tests for any character that is an uppercase letter or is one of an implementation-defined set of characters for which none of iscntrl, isdigit, ispunctor isspace is true. In the "C" locale, isupper returns true only for the characters defined as upper case letters (as defined in ANSI C section 5.2.1).
#include <ctype.h>
int
isxdigit
(int c
);
The isxdigit functions tests for any hexadecimal-digit character (as defined in ANSI C section 6.1.3.2).
[1] |
The current locale is always the C locale. |