HP 3000 Manuals

read [ HP C/iX Library Reference Manual ] MPE/iX 5.0 Documentation


HP C/iX Library Reference Manual

read 

Reads input from a file.

Syntax 

     int read (int fildes, char *buffer, unsigned nbyte);

Parameters 

fildes        An open file descriptor.

buffer        A pointer to a buffer where the function returns data.

nbyte         The number of bytes to read and place in buffer.

Return Values 

>0            Indicates success and the number of bytes read.  This
              number may be less than nbyte if:
                 *   The file is associated with a communication line.
                 *   The number of bytes left in the file is less than
                     nbyte bytes.

EOF           Returned when an end-of-file is reached.

-1            Indicates unsuccessful completion.  The errno variable is
              set if one of the following conditions is true:

              EBADF         The fildes parameter is not a valid file
                            descriptor open for reading.

              ESYSERR       A call to a system intrinsic failed.

Description 

The read function reads nbyte bytes from the file associated with fildes 
and places the data read into the buffer pointed to by buffer.

On devices capable of seeking, read() starts at a position in the file
given by the file offset associated with fildes.  Upon return from
read(), the file pointer is incremented by the number of bytes actually
read.

Devices that are incapable of seeking always read from the current
position.  The value of a file offset associated with such a device is
undefined.

Unless an error occurs, a process blocks until a read() request is
completed.
[REV BEG]


NOTE If linking with the POSIX/iX library, refer to the description of read() located in the MPE/iX Developer's Kit Reference Manual.
[REV END] See Also open(), write()


MPE/iX 5.0 Documentation