PUTC(3S) UNIX Programmer's Manual PUTC(3S) NAME putc, putchar, fputc, putw - put character or word on a stream SYNOPSIS #include int putc(c, stream) char c; FILE *stream; putchar(c) fputc(c, stream) FILE *stream; putw(w, stream) FILE *stream; DESCRIPTION _P_u_t_c appends the character _c to the named output _s_t_r_e_a_m. It returns the character written. _P_u_t_c_h_a_r(_c) is defined as _p_u_t_c(_c, _s_t_d_o_u_t). _F_p_u_t_c behaves like _p_u_t_c, but is a genuine function rather than a macro. It may be used to save on object text. _P_u_t_w appends word (i.e. int) _w to the output _s_t_r_e_a_m. It returns the word written. _P_u_t_w neither assumes nor causes special alignment in the file. The standard stream _s_t_d_o_u_t is normally buffered if and only if the output does not refer to a terminal; this default may be changed by _s_e_t_b_u_f(3S). The standard stream _s_t_d_e_r_r is by default unbuffered unconditionally, but use of _f_r_e_o_p_e_n (see _f_o_p_e_n(3S)) will cause it to become buffered; _s_e_t_b_u_f, again, will set the state to whatever is desired. When an output stream is unbuffered information appears on the destination file or terminal as soon as written; when it is buffered many characters are saved up and written as a block. _F_f_l_u_s_h (see _f_c_l_o_s_e(3S)) may be used to force the block out early. SEE ALSO fclose(3S), fopen(3S), fread(3S), getc(3S), printf(3S), puts(3S) DIAGNOSTICS These functions return the constant EOF upon error. Since this is a good integer, _f_e_r_r_o_r(3S) should be used to detect _p_u_t_w errors. Printed 5/17/83 1 PUTC(3S) UNIX Programmer's Manual PUTC(3S) BUGS Because it is implemented as a macro, _p_u_t_c treats a _s_t_r_e_a_m argument with side effects improperly. In particular `putc(c, *f++);' doesn't work sensibly. Printed 5/17/83 2