NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO
$(OS_DIR)/lib/libc.a #include <stdio.h>int fread(void * ptr, size_t size, size_t nitems, FILE * stream);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
The fread() function copies, into an array pointed to by ptr , nitems items of data from the named input stream , where an item of data is a sequence of bytes (not necessarily terminated by a null byte) of the length size . The fread() function stops appending bytes if an end-of-file or error condition is encountered while reading stream or when nitems items have been read. The fread() function leaves the file pointer in stream , if defined, pointing to the byte following the last byte read. It does not change the contents of stream .
The fwrite() function appends at most nitems items of data from the array pointed to by ptr to the named output stream . The fwrite() function stops appending when it has appended nitems items of data or if an error condition is encountered on stream . It does not change the contents of the array pointed to by ptr .
The size argument is typically sizeof(*ptr) where the pseudo-function sizeof specifies the length of an item pointed to by ptr .
The fread() and fwrite() functions return the number of items read or written. If nitems is negative, no characters are read or written and 0 is returned by both fread() and fwrite() .
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
NAME | SYNOPSIS | API RESTRICTIONS | DESCRIPTION | RETURN VALUES | ATTRIBUTES | SEE ALSO