Character Processing Functions
Non-printable/Printable Tests - iscntrl, isprint,
isgraph and isspace
int iscntrl(int c)
- Returns a nonzero value if
c is a control character,
where control character may differ from machine to machine, but for the
standard 128-character ASCII set, is any character with a value between
0 and 31 or a value equal to 127
int isprint(int c)
- Returns a nonzero value if
c is a printing character,
and on most implementations is the same as (iscntrl(c) ? 0 : 1).
int isgraph(int c)
- Returns a nonzero value if
c is a visible character,
that is, it returns non-zero for everything that isprint
returns non-zero except a space character.
int isspace(int c)
- Returns a nonzero value if
c is a whitespace character.
In ASCII, whitespace characters are
space (' '),
tab ('\t'),
carriage return ('\r'),
newline ('\n'),
vertical tab ('\v') and
formfeed ('\f').
Alphabetic
-
isupper,
islower,
isalpha
int isupper(int c)
- Returns a nonzero value if
c is one of a locale-defined set
of uppercase characters, usually A through Z.
int islower(int c)
- Returns a nonzero value if
c is one of a locale-defined set
of lowercase characters, usually a through z.
int isalpha(int c)
- Returns a nonzero value if
c is either an uppercase or
lowercase character, that is,
and is roughly equivalent to (islower(c) || isupper(c)).
Numeric Tests - isdigit and isxdigit
int isdigit(int c)
- Returns a nonzero value if
c is a decimal digit
(0 through 9)
int isxdigit(int c)
- Returns a nonzero value if
c is a hexadecimal digit
(0 through 9, A through F or
a through f)
Alphanumeric Test - isalnum
int isalnum(int c)
- Returns a nonzero value if
c is either a letter or a
decimal digit
and is roughly equivalent to (isalpha(c) || isdigit(c)).
Punctuation Test - ispunct
int ispunct(int c)
- Returns a nonzero value if
c is a punctuation
character,
that is, it returns non-zero for everything that is neither a space nor
a character for which isalnum returns a nonzero value.
Case Conversion - toupper and tolower
int toupper(int c)
- If
c is a lowercase letter, the corresponding uppercase
letter is returned.
- If
c is not a lowercase letter, c is returned
unchanged.
- Some locales may have lowercase characters with no corresponding
uppercase letter, in which case the lowercase character is returned unchanged.
- Pre-ANSI C implementations of
toupper may not work
correctly if c is not a lowercase character.
int tolower(int c)
tolower is nearly identical to toupper except
that uppercase characters are converted to lowercase characters.
- All caveats which apply to
toupper are equally applicable
to tolower.
Previous,
Next,
Index