Home

iscntrl

iscntrl is a function in the C standard library used to test whether a character is a control character. It is declared in the header <ctype.h> and has the prototype int iscntrl(int ch). The function returns a nonzero value if the argument is a control character according to the current C locale, and zero otherwise.

In the common C locale, control characters are those that do not represent printable characters, typically

The argument ch must be representable as an unsigned char or be the value EOF. Passing a

In languages such as C++, iscntrl is available in <cctype> within the std namespace. It is related

including
ASCII
codes
0x00
through
0x1F
and
0x7F.
However,
the
exact
set
of
characters
classified
as
control
characters
can
vary
with
the
locale
used
by
the
program.
The
classification
is
performed
through
the
program’s
current
locale
data,
so
behavior
may
differ
across
environments.
plain
char
that
is
negative
(on
platforms
where
char
is
signed)
without
casting
can
yield
undefined
behavior.
To
use
iscntrl
safely
with
character
data
of
type
char,
cast
to
unsigned
char:
iscntrl((unsigned
char)ch).
The
function
returns
nonzero
when
ch
is
a
control
character
and
zero
otherwise.
to
other
character
classification
utilities
such
as
isspace,
isprint,
and
isalpha,
and
is
commonly
used
to
filter
or
validate
input,
skip
non-printable
characters,
or
parse
protocol
data.