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