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