1FREAD(3) Linux Programmer's Manual FREAD(3)
2
3
4
6 fread, fwrite - binary stream input/output
7
9 #include <stdio.h>
10
11 size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
12
13 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE
14 *stream);
15
17 The function fread() reads nmemb elements of data, each size bytes
18 long, from the stream pointed to by stream, storing them at the loca‐
19 tion given by ptr.
20
21 The function fwrite() writes nmemb elements of data, each size bytes
22 long, to the stream pointed to by stream, obtaining them from the loca‐
23 tion given by ptr.
24
25 For non-locking counterparts, see unlocked_stdio(3).
26
28 fread() and fwrite() return the number of items successfully read or
29 written (i.e., not the number of characters). If an error occurs, or
30 the end-of-file is reached, the return value is a short item count (or
31 zero).
32
33 fread() does not distinguish between end-of-file and error, and callers
34 must use feof(3) and ferror(3) to determine which occurred.
35
37 C89, POSIX.1-2001.
38
40 read(2), write(2), feof(3), ferror(3), unlocked_stdio(3)
41
42
43
44BSD MANPAGE 1996-05-17 FREAD(3)