Commit | Line | Data |
---|---|---|
ae59e04c | 1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. |
411867e7 | 2 | .\" All rights reserved. |
74188ac6 | 3 | .\" |
411867e7 | 4 | .\" This code is derived from software contributed to Berkeley by |
043368e6 KB |
5 | .\" Chris Torek and the American National Standards Committee X3, |
6 | .\" on Information Processing Systems. | |
7 | .\" | |
411867e7 KB |
8 | .\" %sccs.include.redist.man% |
9 | .\" | |
043368e6 | 10 | .\" @(#)fread.3 6.6 (Berkeley) %G% |
411867e7 | 11 | .\" |
ae59e04c CL |
12 | .Dd |
13 | .Dt FREAD 3 | |
14 | .Os | |
15 | .Sh NAME | |
16 | .Nm fread , | |
17 | .Nm fwrite | |
18 | .Nd binary stream input/output | |
19 | .Sh SYNOPSIS | |
20 | .Fd #include <stdio.h> | |
21 | .Ft int | |
22 | .Fn fread "void *ptr" "size_t size" "size_t nmemb" "FILE *stream" | |
23 | .Ft int | |
24 | .Fn fwrite "void *ptr" "size_t size" "size_t nmemb" "FILE *stream" | |
25 | .Sh DESCRIPTION | |
26 | The function | |
27 | .Fn fread | |
411867e7 | 28 | reads |
ae59e04c CL |
29 | .Fa nmemb |
30 | elements of data, each | |
31 | .Xr size | |
32 | bytes long, from the stream pointed to by | |
33 | .Fa stream , | |
411867e7 | 34 | storing them at the location given by |
ae59e04c CL |
35 | .Fa ptr . |
36 | .Pp | |
37 | The function | |
38 | .Fn fwrite | |
39 | writes | |
40 | .Fa nmemb | |
41 | elements of data, each | |
42 | .Fa size | |
43 | bytes long, to the stream pointed to by | |
44 | .Fa stream , | |
45 | obtaining them from the location given by | |
46 | .Fa ptr . | |
47 | .Sh RETURN VALUES | |
48 | The functions | |
49 | .Fn fread | |
50 | and | |
51 | .Fn fwrite | |
52 | advance the file position indicator for the stream | |
53 | by the number of characters successfully read or written and return | |
54 | that number. | |
55 | If an error occurs, or the end-of-file is reached, | |
56 | the return value is a short character count (or zero). | |
57 | .Pp | |
58 | The function | |
59 | .Fn fread | |
60 | does not distinguish between end-of-file and error, and callers | |
1382c0b2 | 61 | must use |
ae59e04c | 62 | .Xr feof 3 |
1382c0b2 | 63 | and |
ae59e04c | 64 | .Xr ferror 3 |
1382c0b2 | 65 | to determine which occurred. |
ae59e04c CL |
66 | .Sh SEE ALSO |
67 | .Xr read 2 , | |
68 | .Xr write 2 | |
69 | .Sh STANDARDS | |
70 | The functions | |
71 | .Fn fread | |
72 | and | |
73 | .Fn fwrite | |
74 | conform to | |
75 | .St -ansiC . |