Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>_read() read data from a file</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
_read()                  Read Data from a File

 #include   <io.h>

 int        _read(handle,buf,nbyte);
 int        handle;                      Handle associated with file
 void       *buf;                        Buffer
 int        nbyte;                       Number of bytes to be read

    _read() attempts to read 'nbytes' bytes from the file associated with
    'handle' into the buffer pointed to by 'buf'.  _read() is a direct
    call to the MS-DOS read system call.  'handle' is a file handle
    obtained from a creat(), open(), dup(), dup2() or fcntl() call.
    _read() begins reading disk files at the current file pointer
    position.  When the reading is complete, the file pointer is
    incremented by the number of bytes read.  On devices, bytes are read
    directly from the device.

    Returns:    If successful, the number of bytes read and placed in the
                buffer is returned.  On end-of-file, 0 is returned.  On
                error, _1 is returned and 'errno' (defined in <stdlib.h>)
                is set to one of the following:

                    EACCES         Permission denied
                    EBADF          Bad file number

      Notes:    _read() does not remove carriage returns (as read() does)
                and does not report end-of-file when a Ctrl-Z character
                is read.

See Also: creat() dup() fread() open() read()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson