Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with 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
 unsigned   nbyte;                       Number of bytes to be read

    _read() attempts to read 'nbyte' bytes from the file or device
    associated with 'handle' into the buffer pointed to by 'buf'.
    _read() is a direct call to the DOS read system call 0X3F.  '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.  On completion, it increments the file pointer by
    the number of bytes read.  On devices, _read() reads bytes 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 <errno.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. If you are reading more than 32K
                    (the maximum size for type 'int') from a file, the
                    return value should be of type 'unsigned int'.  The
                    maximum number of bytes that can be read is 65534.
                    (65535, or 0XFFFF, is indistinguishable from -1, and
                    will return an error.)

   Portability:     MS-DOS only.


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

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