putc(3s)
NAME
putc, putchar, fputc, putw − put character or word on a stream
SYNTAX
#include <stdio.h>
int putc(c, stream)
char c;
FILE *stream;
putchar(c)
fputc(c, stream)
FILE *stream;
putw(w, stream)
FILE *stream;
DESCRIPTION
The putc routine appends the character c to the named output stream. It returns the character written.
The putchar(c) routine is defined as putc (c, stdout).
The fputc routine behaves like putc, but is a genuine function rather than a macro.
The putw routine appends word (that is, int) w to the output stream. It returns the word written. The putw routine neither assumes nor causes special alignment in the file.
DIAGNOSTICS
These functions return the constant EOF upon error. Since this is a good integer, ferror() should be used to detect putw errors.
RESTRICTIONS
Because it is implemented as a macro, putc treats a stream argument with side effects incorrectly. In particular, ‘putc(c, *f++);’ doesn’t work as expected.
SEE ALSO
fclose (3s), fopen(3s), fread(3s), getc(3s), printf(3s), puts(3s)