FREAD

Section: Standard I/O Functions (3S)
Updated: August 1, 1992
Index Return to Main Contents
 

NAME

fread, fwrite - buffered binary input/output  

SYNOPSIS

#include <stdio.h>

size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);

size_t fwrite(void *ptr, size_t size, size_t nitems, FILE *stream);  

DESCRIPTION

Fread reads, into a block beginning at ptr, nitems of data of the size of size from the named input stream. It returns the number of items actually read.

If stream is stdin and the standard output is line buffered, then any partial output line will be flushed before any call to read(2) to satisfy the fread.

Fwrite appends at most nitems of data of the size of size beginning at ptr to the named output stream. It returns the number of items actually written.  

RETURN VALUE

Fread returns the number of elements successfully read, which may be less than nitems if a read error or end-of-file is encountered.

Fwrite returns the number of elements successfully written, which may be less than nitems if a write error is encountered.  

ERRORS

The underlying function of fread is read. The underlying function of fwrite is write. The errors detected for fread and fwrite are those specified for their respective underlying function.  

SEE ALSO

read(2), write(2), fopen(3S), getc(3S), putc(3S), gets(3S), puts(3S), printf(3S), scanf(3S)


 

Index

NAME
SYNOPSIS
DESCRIPTION
RETURN VALUE
ERRORS
SEE ALSO

This document was created by man2html, using the manual pages.
Time: 00:57:36 GMT, September 26, 2024