Commit | Line | Data |
---|---|---|
e6817382 BJ |
1 | .TH SETBUF 3S |
2 | .SH NAME | |
3 | setbuf \- assign buffering to a stream | |
4 | .SH SYNOPSIS | |
5 | .B #include <stdio.h> | |
6 | .PP | |
7 | .B setbuf(stream, buf) | |
8 | .br | |
9 | .SM | |
10 | .B FILE | |
11 | .B *stream; | |
12 | .br | |
13 | .B char *buf; | |
14 | .SH DESCRIPTION | |
15 | .I Setbuf | |
16 | is used after a stream has been opened but before it | |
17 | is read or written. | |
18 | It causes the character array | |
19 | .I buf | |
20 | to be used instead of an automatically allocated buffer. | |
21 | If | |
22 | .I buf | |
23 | is the constant pointer | |
24 | .SM | |
25 | .B NULL, | |
26 | input/output will be completely unbuffered. | |
27 | .PP | |
28 | A manifest constant | |
29 | .SM | |
30 | .B BUFSIZ | |
31 | tells how big an array is needed: | |
32 | .PP | |
33 | .in +10 | |
34 | char buf[BUFSIZ]; | |
35 | .PP | |
36 | A buffer is normally obtained from | |
37 | .IR malloc (3) | |
38 | upon the first | |
39 | .I getc | |
40 | or | |
41 | .IR putc (3) | |
42 | on the file, | |
43 | except that output streams directed to terminals, | |
44 | and the standard error stream | |
45 | .I stderr | |
46 | are normally not buffered. | |
47 | .SH "SEE ALSO" | |
48 | fopen(3), getc(3), putc(3), malloc(3) |