Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fwrite(3S) — DG/UX 5.4.2A

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cc(1)

gcc(1)

exit(2)

lseek(2)

read(2)

write(2)

abort(3C)

fclose(3S)

fopen(3S)

getc(3S)

gets(3S)

printf(3S)

putc(3S)

puts(3S)

scanf(3S)

stdio(3S)



fread(3S)                        DG/UX 5.4.2                       fread(3S)


NAME
       fread, fwrite - binary input/output

SYNOPSIS
       #include <stdio.h>

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

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

DESCRIPTION
       fread reads into an array pointed to by ptr up to nitems items of
       data from stream, where an item of data is a sequence of bytes (not
       necessarily terminated by a null byte) of length size.  fread stops
       reading bytes if an end-of-file or error condition is encountered
       while reading stream, or if nitems items have been read.  fread
       increments the data pointer in stream to point to the byte following
       the last byte read if there is one.  fread does not change the
       contents of stream.  fread returns the number of items read.

       fwrite writes to the named output stream at most nitems items of data
       from the array pointed to by ptr, where an item of data is a sequence
       of bytes (not necessarily terminated by a null byte) of length size.
       fwrite stops writing when it has written nitems items of data or if
       an error condition is encountered on stream.  fwrite does not change
       the contents of the array pointed to by ptr.  fwrite increments the
       data-pointer in stream by the number of bytes written.  fwrite
       returns the number of items written.

       If size or nitems is zero, then fread and fwrite return a value of 0
       and do not effect the state of stream.

       The ferror or feof routines must be used to distinguish between an
       error condition and end-of-file condition upon fread or fwrite
       returning a value of 0.

SEE ALSO
       cc(1), gcc(1), exit(2), lseek(2), read(2), write(2), abort(3C),
       fclose(3S), fopen(3S), getc(3S), gets(3S), printf(3S), putc(3S),
       puts(3S), scanf(3S), stdio(3S).

NOTES
       When STDC is not defined during compilation (see the cc(1) and/or
       gcc(1)man pages), the return types of fread and fwrite are int, not
       sizet as stated above.  This is done to comply with the
       traditional/transitional compilation mode.

DIAGNOSTICS
       If an error occurs, the error indicator for stream is set.  If fread
       (fwrite) was called with a stream that was not opened for reading
       (writing) then errno will be set to EBADF.





Licensed material--property of copyright holder(s)                         1


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026