PUTC(3S)
NAME
putc, putchar, fputc, putw − put character or word on a stream
USAGE
#include <stdio.h>
int putc(c, stream) char c; FILE *stream;
putchar(c)
fputc(c, stream) char c; FILE *stream;
putw(w, stream) FILE *stream;
DESCRIPTION
The macro Putc appends the character c 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 function rather than a macro.
Putw appends word (i.e., int) w to the output stream. It returns the word written. Putw neither assumes nor causes special alignment in the file.
NOTES
Because it is implemented as a macro, putc treats a stream argument with side effects improperly. In particular, “putc(c, *f++);” doesn’t work correctly.
An error generated by a putc call can appear long after the erroneous call is executed.
DIAGNOSTICS
These functions return the constant EOF upon error. Since this is a good integer, you must use ferror(3S) to detect putw errors.
RELATED INFORMATION
fopen(3S), fclose(3S), getc(3S), puts(3S), printf(3S), fread(3S)