Blame man3/fread.3

Packit 7cfc04
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
Packit 7cfc04
.\" All rights reserved.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This code is derived from software contributed to Berkeley by
Packit 7cfc04
.\" Chris Torek and the American National Standards Committee X3,
Packit 7cfc04
.\" on Information Processing Systems.
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
Packit 7cfc04
.\" Redistribution and use in source and binary forms, with or without
Packit 7cfc04
.\" modification, are permitted provided that the following conditions
Packit 7cfc04
.\" are met:
Packit 7cfc04
.\" 1. Redistributions of source code must retain the above copyright
Packit 7cfc04
.\"    notice, this list of conditions and the following disclaimer.
Packit 7cfc04
.\" 2. Redistributions in binary form must reproduce the above copyright
Packit 7cfc04
.\"    notice, this list of conditions and the following disclaimer in the
Packit 7cfc04
.\"    documentation and/or other materials provided with the distribution.
Packit 7cfc04
.\" 3. All advertising materials mentioning features or use of this software
Packit 7cfc04
.\"    must display the following acknowledgement:
Packit 7cfc04
.\"	This product includes software developed by the University of
Packit 7cfc04
.\"	California, Berkeley and its contributors.
Packit 7cfc04
.\" 4. Neither the name of the University nor the names of its contributors
Packit 7cfc04
.\"    may be used to endorse or promote products derived from this software
Packit 7cfc04
.\"    without specific prior written permission.
Packit 7cfc04
.\"
Packit 7cfc04
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
Packit 7cfc04
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 7cfc04
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit 7cfc04
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
Packit 7cfc04
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 7cfc04
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit 7cfc04
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit 7cfc04
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit 7cfc04
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit 7cfc04
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit 7cfc04
.\" SUCH DAMAGE.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.\"     @(#)fread.3	6.6 (Berkeley) 6/29/91
Packit 7cfc04
.\"
Packit 7cfc04
.\" Converted for Linux, Mon Nov 29 15:37:33 1993, faith@cs.unc.edu
Packit 7cfc04
.\" Sun Feb 19 21:26:54 1995 by faith, return values
Packit 7cfc04
.\" Modified Thu Apr 20 20:43:53 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
Packit 7cfc04
.\" Modified Fri May 17 10:21:51 1996 by Martin Schulze <joey@infodrom.north.de>
Packit 7cfc04
.\"
Packit 7cfc04
.TH FREAD 3  2015-07-23 "GNU" "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
fread, fwrite \- binary stream input/output
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.nf
Packit 7cfc04
.B #include <stdio.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb \
Packit 7cfc04
", FILE *" stream );
Packit 7cfc04
.PP
Packit 7cfc04
.BI "size_t fwrite(const void *" ptr ", size_t " size ", size_t " nmemb ,
Packit 7cfc04
.BI "              FILE *" stream );
Packit 7cfc04
.fi
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
The function
Packit 7cfc04
.BR fread ()
Packit 7cfc04
reads
Packit 7cfc04
.I nmemb
Packit 7cfc04
items of data, each
Packit 7cfc04
.I size
Packit 7cfc04
bytes long, from the stream pointed to by
Packit 7cfc04
.IR stream ,
Packit 7cfc04
storing them at the location given by
Packit 7cfc04
.IR ptr .
Packit 7cfc04
.PP
Packit 7cfc04
The function
Packit 7cfc04
.BR fwrite ()
Packit 7cfc04
writes
Packit 7cfc04
.I nmemb
Packit 7cfc04
items of data, each
Packit 7cfc04
.I size
Packit 7cfc04
bytes long, to the stream pointed to by
Packit 7cfc04
.IR stream ,
Packit 7cfc04
obtaining them from the location given by
Packit 7cfc04
.IR ptr .
Packit 7cfc04
.PP
Packit 7cfc04
For nonlocking counterparts, see
Packit 7cfc04
.BR unlocked_stdio (3).
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR fread ()
Packit 7cfc04
and
Packit 7cfc04
.BR fwrite ()
Packit 7cfc04
return the number of items read or written.
Packit 7cfc04
This number equals the number of bytes transferred only when
Packit 7cfc04
.I size
Packit 7cfc04
is 1.
Packit 7cfc04
If an error occurs, or the end of the file is reached,
Packit 7cfc04
the return value is a short item count (or zero).
Packit 7cfc04
.PP
Packit 7cfc04
.BR fread ()
Packit 7cfc04
does not distinguish between end-of-file and error, and callers must use
Packit 7cfc04
.BR feof (3)
Packit 7cfc04
and
Packit 7cfc04
.BR ferror (3)
Packit 7cfc04
to determine which occurred.
Packit 7cfc04
.SH ATTRIBUTES
Packit 7cfc04
For an explanation of the terms used in this section, see
Packit 7cfc04
.BR attributes (7).
Packit 7cfc04
.TS
Packit 7cfc04
allbox;
Packit 7cfc04
lbw17 lb lb
Packit 7cfc04
l l l.
Packit 7cfc04
Interface	Attribute	Value
Packit 7cfc04
T{
Packit 7cfc04
.BR fread (),
Packit 7cfc04
.BR fwrite ()
Packit 7cfc04
T}	Thread safety	MT-Safe
Packit 7cfc04
.TE
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
POSIX.1-2001, POSIX.1-2008, C89.
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR read (2),
Packit 7cfc04
.BR write (2),
Packit 7cfc04
.BR feof (3),
Packit 7cfc04
.BR ferror (3),
Packit 7cfc04
.BR unlocked_stdio (3)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.