PUTC
Section: Standard I/O Functions (3S)
Updated: August 1, 1992
Index
Return to Main Contents
NAME
putc, putchar, fputc - put character on a stream
SYNOPSIS
#include <stdio.h>
int putc(int c, FILE *stream);
int putchar(int c);
int fputc(int c, FILE *stream);
int putw(int w, FILE *stream);
DESCRIPTION
Putc
appends the character
c
(converted to an unsigned char)
to the named output
stream.
It returns the character written.
Putchar(c)
is defined as
putc(c,
stdout).
Fputc
behaves like
putc,
but is a genuine function rather than a macro.
Putw
appends word
(that is, an
int)
w
to the output
stream.
It returns the word written.
Putw
neither assumes nor causes special alignment in the file.
Putw
is
neither ANSI- nor POSIX-compliant.
RETURN VALUE
These functions return the character written.
If a write error occurs,
the error indicator for the stream is set,
errno
is set, and
EOF
is returned.
Since
EOF
is a valid integer,
ferror(3S)
should be used to detect
putw
errors.
ERRORS
The underlying function of these functions
is write(2). The error conditions specified for read(2)
apply to
them.
BUGS
Because it is implemented as a macro,
putc
treats a
stream
argument with side effects improperly. In particular
``putc(c, *f++)''
doesn't work sensibly.
Errors can occur long after the call to
putc.
SEE ALSO
fopen(3S),
fclose(3S),
getc(3S),
puts(3S),
printf(3S),
fread(3S)
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- RETURN VALUE
-
- ERRORS
-
- BUGS
-
- SEE ALSO
-
This document was created by
man2html,
using the manual pages.
Time: 17:20:30 GMT, March 25, 2025