Home

isctype

isctype is a function from the C standard library interfaces that tests whether a given character belongs to a specified character class. It is commonly found on POSIX-compliant systems and in some C libraries (such as those used on Unix-like systems and some Windows environments), but it is not part of the ISO C standard. The function is useful for character classification that may depend on locale settings beyond the basic ASCII categories.

The typical declaration is int isctype(int c, int type); both parameters are integers. The first parameter represents

Usage notes and portability considerations are important. Because isctype is not mandated by the ISO C standard,

Example (illustrative, not portable across all implementations):

#include <ctype.h>

int c = 'A';

if (isctype(c, DIGIT)) { /* handle digit */ }

the
character
to
test,
usually
supplied
as
an
unsigned
char
promoted
to
int,
or
as
EOF.
The
second
parameter
is
a
bitmask
describing
the
character
class
to
test
against,
such
as
digits,
letters,
whitespace,
punctuation,
or
other
locale-dependent
categories.
The
exact
set
and
names
of
the
bitmasks
are
implementation-defined,
but
they
generally
correspond
to
common
classes
like
upper-case
letters,
lower-case
letters,
digits,
whitespace,
and
punctuation.
The
function
returns
a
non-zero
value
if
the
character
belongs
to
the
requested
class
and
zero
otherwise,
with
behavior
influenced
by
the
current
locale.
developers
should
verify
availability
in
their
target
environments.
When
portability
is
critical,
equivalent
checks
using
standard
C
library
functions
such
as
isalpha,
isdigit,
isspace,
and
friends
can
be
more
reliable;
are
often
preferred
because
they
do
not
rely
on
non-standard
variants
and
are
locale-aware
through
the
standard
facilities.
For
wide
characters,
wide-character
variants
such
as
iswctype
are
available
and
operate
with
wide
character
types
and
corresponding
masks.