lseek

Moves the file pointer

int lseek (
        int fd,
        u_int offset,
        int flag
)

Arguments

fd File descriptor
offset Offset
flag See below

Return Value

The current file pointer is returned if the function succeeded.
-1 is returned in all other cases.

Explanation

The file pointer of the device corresponding to the file descriptor specified by fd is moved according to the values of offset and flag.
offset specifies the number of bytes to move the pointer.
flag has the meaning indicated below:

Flag Macro Function
SEEK_SET Seek from the beginning of file. offset is relative to the beginning of the file.
SEEK_CUR Seek from the current location. offset is relative from the current position of the file pointer.

lseek() cannot be used with character-type drivers.

See Also

open(), read(), write()