2004-11-03 13:51:07 +00:00
|
|
|
.\" Copyright (c) 1990, 1991 The Regents of the University of California.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to Berkeley by
|
|
|
|
.\" Chris Torek and the American National Standards Committee X3,
|
|
|
|
.\" on Information Processing Systems.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)fread.3 6.6 (Berkeley) 6/29/91
|
|
|
|
.\"
|
|
|
|
.\" Converted for Linux, Mon Nov 29 15:37:33 1993, faith@cs.unc.edu
|
|
|
|
.\" Sun Feb 19 21:26:54 1995 by faith, return values
|
|
|
|
.\" Modified Thu Apr 20 20:43:53 1995 by Jim Van Zandt <jrv@vanzandt.mv.com>
|
|
|
|
.\" Modified Fri May 17 10:21:51 1996 by Martin Schulze <joey@infodrom.north.de>
|
|
|
|
.\"
|
2012-03-29 18:55:26 +00:00
|
|
|
.TH FREAD 3 2012-03-30 "GNU" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
fread, fwrite \- binary stream input/output
|
|
|
|
.SH SYNOPSIS
|
2007-04-03 15:32:52 +00:00
|
|
|
.nf
|
2004-11-03 13:51:07 +00:00
|
|
|
.B #include <stdio.h>
|
|
|
|
.sp
|
2007-04-03 15:32:52 +00:00
|
|
|
.BI "size_t fread(void *" ptr ", size_t " size ", size_t " nmemb \
|
|
|
|
", FILE *" stream );
|
2004-11-03 13:51:07 +00:00
|
|
|
.sp
|
|
|
|
.BI "size_t fwrite(const void *" ptr ", size_t " size ", size_t " nmemb ,
|
2007-04-03 15:32:52 +00:00
|
|
|
.BI " FILE *" stream );
|
|
|
|
.fi
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
|
|
|
The function
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fread ()
|
2004-11-03 13:51:07 +00:00
|
|
|
reads
|
|
|
|
.I nmemb
|
|
|
|
elements of data, each
|
|
|
|
.I size
|
|
|
|
bytes long, from the stream pointed to by
|
|
|
|
.IR stream ,
|
|
|
|
storing them at the location given by
|
|
|
|
.IR ptr .
|
|
|
|
.PP
|
|
|
|
The function
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fwrite ()
|
2004-11-03 13:51:07 +00:00
|
|
|
writes
|
|
|
|
.I nmemb
|
|
|
|
elements of data, each
|
|
|
|
.I size
|
|
|
|
bytes long, to the stream pointed to by
|
|
|
|
.IR stream ,
|
|
|
|
obtaining them from the location given by
|
|
|
|
.IR ptr .
|
|
|
|
.PP
|
accept.2, access.2, acct.2, clock_nanosleep.2, mbind.2, mincore.2, remap_file_pages.2, sched_setscheduler.2, set_mempolicy.2, splice.2, stat.2, syslog.2, timer_create.2, timerfd_create.2, truncate.2, fenv.3, ferror.3, fflush.3, fgetwc.3, fgetws.3, flockfile.3, fputwc.3, fputws.3, fread.3, getopt.3, gets.3, getwchar.3, glob.3, iconv.3, longjmp.3, pow.3, printf.3, puts.3, putwchar.3, regex.3, rpc.3, scanf.3, setjmp.3, termios.3, unlocked_stdio.3, wcswidth.3, hd.4, rtc.4, st.4, core.5, dir_colors.5, elf.5, proc.5, arp.7, ascii.7, boot.7, bootparam.7, charsets.7, futex.7, ip.7, iso_8859-11.7, man-pages.7, man.7, mdoc.samples.7, path_resolution.7, pipe.7, posixoptions.7, unicode.7, unix.7, uri.7, utf-8.7, ld.so.8: s/non-/non/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:20:12 +00:00
|
|
|
For nonlocking counterparts, see
|
2004-11-03 13:51:07 +00:00
|
|
|
.BR unlocked_stdio (3).
|
|
|
|
.SH "RETURN VALUE"
|
2012-03-29 18:55:26 +00:00
|
|
|
On success,
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fread ()
|
2004-11-03 13:51:07 +00:00
|
|
|
and
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fwrite ()
|
2012-03-29 18:55:26 +00:00
|
|
|
return the number of
|
|
|
|
.I items
|
|
|
|
read or written.
|
|
|
|
This number equals the number of bytes transferred only when
|
|
|
|
.I size
|
|
|
|
is 1.
|
|
|
|
If an error occurs, or the end of the file is reached,
|
|
|
|
the return value is a short item count (or zero).
|
2004-11-03 13:51:07 +00:00
|
|
|
.PP
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fread ()
|
2004-11-03 13:51:07 +00:00
|
|
|
does not distinguish between end-of-file and error, and callers must use
|
|
|
|
.BR feof (3)
|
|
|
|
and
|
|
|
|
.BR ferror (3)
|
|
|
|
to determine which occurred.
|
|
|
|
.SH "CONFORMING TO"
|
2006-08-03 13:57:30 +00:00
|
|
|
C89, POSIX.1-2001.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR read (2),
|
|
|
|
.BR write (2),
|
|
|
|
.BR feof (3),
|
|
|
|
.BR ferror (3),
|
|
|
|
.BR unlocked_stdio (3)
|