Home

putc

Putc is a standard C library function used to write a single character to a file stream. It is declared in stdio.h and is part of the C standard I/O facilities. The typical prototype is int putc(int ch, FILE *stream).

Behavior and return value: putc converts the given integer ch to unsigned char and writes that character

Relation to related functions: putc is intended to have the same effect as fputc. In many implementations,

Usage considerations: Because putc may be implemented as a macro, programmers should be aware of potential

See also: fputc, putchar, stdio.h, FILE.

to
the
specified
stream.
On
success,
it
returns
the
character
written,
promoted
to
int.
If
an
error
occurs
or
the
stream
cannot
be
written
to,
it
returns
EOF.
The
character
value
should
be
representable
as
unsigned
char;
passing
values
outside
this
range
yields
undefined
behavior.
putc
may
be
defined
as
a
macro
for
efficiency,
which
can
affect
how
arguments
are
evaluated
(potentially
more
than
once).
fputc
is
the
corresponding
function
that
performs
the
same
operation
as
a
function
call.
putchar
is
a
convenience
wrapper
that
writes
to
stdout
and
is
equivalent
to
putc
with
stdout
as
the
stream.
multiple
evaluations
of
its
arguments
in
some
environments.
The
return
value
being
EOF
on
error
provides
a
way
to
detect
failures.
In
portable
code,
you
can
use
putc
where
a
specific
FILE*
stream
is
targeted,
or
use
putchar
when
writing
to
standard
output.