01.01.2013 Views

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

AT&T UNIX™PC Unix System V Users Manual - tenox

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

FREAD ( 3S ) FREAD ( 3S )<br />

NAME<br />

fread, fwrite - binary input/output<br />

SYNOPSIS<br />

#include <br />

int fread (ptr, size, nitems, stream)<br />

char *ptr;<br />

int size, niterns;<br />

FILE *stream;<br />

int fw rite (ptr, size, nitems, stream)<br />

char *ptr;<br />

int size, nitems;<br />

FILE *stream;<br />

DESCRIPTION<br />

Fread copies, into an array beginning at ptr , nit ems items of data<br />

from the named input stream, where an item of data is a sequence<br />

of bytes (not necessarily terminated by a null byte) of length size .<br />

Fread stops appending bytes if an end-of-file or error condition is<br />

encountered while reading stream, or if nitems items have been<br />

read. Fread leaves the file pointer in stream , if defined, pointing<br />

to the byte following the last byte read if there is one. Fread<br />

does not change the contents of stream.<br />

Fwrite appends at most nitems items of data from the the array<br />

pointed to by ptr to the named output stream . Fwrite stops<br />

appending when it has appended nitems items of data or if an<br />

error condition is encountered on stream . Fwrite does not change<br />

the contents of the array pointed to by ptr.<br />

The variable size is typically sizeof(•ptr) where the pseudofunction<br />

size of specifies the length of an item pointed to by ptr.<br />

If ptr points to a data type other than char it should be cast into<br />

a pointer to char.<br />

SEE ALSO<br />

read(2), write(2), fopen(3S), getc(3S), gets(3S), printf(3S), putc(3S),<br />

puts(3S), scanf(3S).<br />

DIAGNOSTICS<br />

Fread and fwrite return the number of items read or written. If<br />

nitems is non-positive, no characters are read or written and 0 is<br />

returned by both fread and fwrite.<br />

- 1 -

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!