Bell 32V release
[unix-history] / usr / man / man3 / putc.3s
CommitLineData
187e2969
TL
1.TH PUTC 3S
2.SH NAME
3putc, putchar, fputc, putw \- put character or word on a stream
4.SH SYNOPSIS
5.B #include <stdio.h>
6.PP
7.B int putc(c, stream)
8.br
9.B char c;
10.br
11.SM
12.B FILE
13.B *stream;
14.PP
15.B putchar(c)
16.PP
17.B fputc(c, stream)
18.br
19.SM
20.B FILE
21.B *stream;
22.PP
23.B putw(w, stream)
24.br
25.SM
26.B FILE
27.B *stream;
28.SH DESCRIPTION
29.I Putc
30appends the character
31.I c
32to the named output
33.IR stream .
34It returns the character written.
35.PP
36.I Putchar(c)
37is defined as
38.I "putc(c, stdout)."
39.PP
40.I Fputc
41behaves like
42.I putc,
43but is a genuine function rather than a macro.
44It may be used to save on object text.
45.PP
46.I Putw
47appends word
48(i.e.
49.BR int )
50.I w
51to the output
52.IR stream .
53It returns the word written.
54.I Putw
55neither assumes nor causes special alignment in the file.
56.PP
57The standard stream
58.I stdout
59is normally buffered if and only if the
60output does not refer to a terminal;
61this default may be changed by
62.IR setbuf (3).
63The standard stream
64.I stderr
65is by default unbuffered unconditionally,
66but use of
67.I freopen
68(see
69.IR fopen (3))
70will cause it to become buffered;
71.IR setbuf ,
72again, will set the state to whatever is desired.
73When an output stream is unbuffered information appears on the
74destination file or terminal as soon as written;
75when it is buffered many characters are saved up and written as a block.
76.I Fflush
77(see
78.IR fclose (3))
79may be used to force the block out early.
80.SH "SEE ALSO"
81fopen(3), fclose(3), getc(3),
82puts(3), printf(3),
83fread(3)
84.SH DIAGNOSTICS
85These functions return the constant
86.SM
87.B EOF
88upon error.
89Since this is a good integer,
90.IR ferror (3)
91should be used to detect
92.I putw
93errors.
94.SH BUGS
95Because it is implemented as a macro,
96.I putc
97treats a
98.I stream
99argument with side effects improperly.
100In particular
101`putc(c, *f++);'
102doesn't work sensibly.