1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)fread.3 6.5 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt FREAD 3 12.Os 13.Sh NAME 14.Nm fread , 15.Nm fwrite 16.Nd binary stream input/output 17.Sh SYNOPSIS 18.Fd #include <stdio.h> 19.Ft int 20.Fn fread "void *ptr" "size_t size" "size_t nmemb" "FILE *stream" 21.Ft int 22.Fn fwrite "void *ptr" "size_t size" "size_t nmemb" "FILE *stream" 23.Sh DESCRIPTION 24The function 25.Fn fread 26reads 27.Fa nmemb 28elements of data, each 29.Xr size 30bytes long, from the stream pointed to by 31.Fa stream , 32storing them at the location given by 33.Fa ptr . 34.Pp 35The function 36.Fn fwrite 37writes 38.Fa nmemb 39elements of data, each 40.Fa size 41bytes long, to the stream pointed to by 42.Fa stream , 43obtaining them from the location given by 44.Fa ptr . 45.Sh RETURN VALUES 46The functions 47.Fn fread 48and 49.Fn fwrite 50advance the file position indicator for the stream 51by the number of characters successfully read or written and return 52that number. 53If an error occurs, or the end-of-file is reached, 54the return value is a short character count (or zero). 55.Pp 56The function 57.Fn fread 58does not distinguish between end-of-file and error, and callers 59must use 60.Xr feof 3 61and 62.Xr ferror 3 63to determine which occurred. 64.Sh SEE ALSO 65.Xr read 2 , 66.Xr write 2 67.Sh STANDARDS 68The functions 69.Fn fread 70and 71.Fn fwrite 72conform to 73.St -ansiC . 74