1FREAD(3)                   Linux Programmer's Manual                  FREAD(3)
2
3
4

NAME

6       fread, fwrite - binary stream input/output
7

SYNOPSIS

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,
14                     FILE *stream);
15

DESCRIPTION

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 nonlocking counterparts, see unlocked_stdio(3).
26

RETURN VALUE

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

CONFORMING TO

37       C89, POSIX.1-2001.
38

SEE ALSO

40       read(2), write(2), feof(3), ferror(3), unlocked_stdio(3)
41

COLOPHON

43       This  page  is  part of release 3.25 of the Linux man-pages project.  A
44       description of the project, and information about reporting  bugs,  can
45       be found at http://www.kernel.org/doc/man-pages/.
46
47
48
49GNU                               1996-05-17                          FREAD(3)
Impressum