Function lseek

Top 

Declaration:

long lseek(long handle, long offset, int fromwhere);

Description

Moves file pointer.

lseek sets the file pointer associated with handle to a new position, which is offset bytes beyond the file location specified by fromwhere. fromwhere must be one of the following symbolic constants (defined in system.h):

 

-----------------------------------------

SEEK_CUR     Current file pointer position

SEEK_END     End-of-file

SEEK_SET     File beginning

Returned Value

lseek returns the offset of the pointer new position measured in bytes from the file beginning. lseek returns -1L on error, and the errno global variable is set to one of the following values:

EBADF        Bad file handle

EINVAL       Invalid argument

ESPIPE       Illegal seek on device

For the devices incapable of seeking (such as terminals or printers), the return value is undefined.