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 items of data, each size bytes long,
18       from the stream pointed to by stream,  storing  them  at  the  location
19       given by ptr.
20
21       The function fwrite() writes nmemb items of data, each size bytes long,
22       to the stream pointed to by stream, obtaining them  from  the  location
23       given by ptr.
24
25       For nonlocking counterparts, see unlocked_stdio(3).
26

RETURN VALUE

28       On  success,  fread()  and  fwrite() return the number of items read or
29       written.  This number equals the number of bytes transferred only  when
30       size  is 1.  If an error occurs, or the end of the file is reached, the
31       return value is a short item count (or 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

ATTRIBUTES

37       For   an   explanation   of   the  terms  used  in  this  section,  see
38       attributes(7).
39
40       ┌──────────────────┬───────────────┬─────────┐
41Interface         Attribute     Value   
42       ├──────────────────┼───────────────┼─────────┤
43fread(), fwrite() │ Thread safety │ MT-Safe │
44       └──────────────────┴───────────────┴─────────┘

CONFORMING TO

46       POSIX.1-2001, POSIX.1-2008, C89.
47

SEE ALSO

49       read(2), write(2), feof(3), ferror(3), unlocked_stdio(3)
50

COLOPHON

52       This page is part of release 5.07 of the Linux  man-pages  project.   A
53       description  of  the project, information about reporting bugs, and the
54       latest    version    of    this    page,    can     be     found     at
55       https://www.kernel.org/doc/man-pages/.
56
57
58
59GNU                               2015-07-23                          FREAD(3)
Impressum