Commit | Line | Data |
---|---|---|
411867e7 KB |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
74188ac6 | 3 | .\" |
411867e7 KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" Chris Torek. | |
74188ac6 | 6 | .\" |
411867e7 KB |
7 | .\" %sccs.include.redist.man% |
8 | .\" | |
1382c0b2 | 9 | .\" @(#)fread.3 6.4 (Berkeley) %G% |
411867e7 KB |
10 | .\" |
11 | .TH FREAD 3 "" | |
12 | .UC 7 | |
74188ac6 | 13 | .SH NAME |
411867e7 | 14 | fread, fwrite \- stream binary input/output |
74188ac6 | 15 | .SH SYNOPSIS |
411867e7 KB |
16 | .nf |
17 | .ft B | |
18 | #include <stdio.h> | |
19 | ||
20 | int | |
21 | fread(void *ptr, size_t size, size_t count, FILE *stream); | |
22 | ||
23 | int | |
24 | fwrite(void *ptr, size_t size, size_t count, FILE *stream); | |
25 | .ft R | |
26 | .fi | |
74188ac6 KM |
27 | .SH DESCRIPTION |
28 | .I Fread | |
411867e7 KB |
29 | reads |
30 | .I count | |
31 | items of data, each | |
32 | .I size | |
33 | bytes long, from the given input | |
34 | .IR stream , | |
35 | storing them at the location given by | |
36 | .IR ptr . | |
37 | It returns the actual count of items read | |
38 | (which will be less than | |
39 | .I count | |
40 | in the event of an | |
41 | .B EOF | |
42 | or error). | |
74188ac6 | 43 | .PP |
1382c0b2 KB |
44 | Fread does not distinguish between end-of-file and error, and callers |
45 | must use | |
46 | .IR feof (3) | |
47 | and | |
48 | .IR ferror (3) | |
49 | to determine which occurred. | |
50 | .PP | |
74188ac6 | 51 | .I Fwrite |
411867e7 KB |
52 | writes |
53 | .I count | |
54 | items of data, each | |
55 | .I size | |
56 | bytes long, to the given output | |
57 | .I stream , | |
58 | obtaining them from the location given by | |
59 | .IR ptr . | |
60 | It returns the actual count of items written. | |
61 | .SH "RETURN VALUE" | |
62 | These functions return 0 (or a short count) upon end of file or error. | |
74188ac6 | 63 | .SH "SEE ALSO" |
1382c0b2 | 64 | read(2), write(2) |