![]() |
|
| << Previous | Next >> | |
| | |
int fread( File * f, void * buf, int len );
Description
- Read data from the "current position" of the given file. When the file is opened, the current position is 0, meaning the start of the file. Subsequent reads or writes advance the position by the number of bytes read or written.
fseek()can also be used to position the read point.
- If the application permits, it is much more efficient to read multiple data bytes rather than reading one-by-one.
Parameters
- f
- Pointer to file descriptor (initialized by
fopen_rd(),fopen_wr()orfcreate()).
- buf
- Data buffer located in root data memory or stack. This must be dimensioned with at least len bytes.
- len
- Length of data to read (0 to 32767 inclusive).
Return value
len: Success.
<len: Partial success. Returns amount successfully read.errnogives further details (probably 0 meaning that end-of-file was encountered).
0: Failure, orlenwas zero.Library
- FS2.LIB
ERRNO values
EBADFD- File descriptor not opened.
EINVAL-lenless than zero.
0- Success, butlenwas zero or EOF was reached prior to readinglenbytes.
EIO- I/O error.See also
- fseek (FS2), fwrite (FS2)
| Dynamic C Functions | << Previous | Next >> | rabbit.com |