Digital UNIX Diffs - lseek(5) Digital UNIX Diffs - lseek(5)NAMElseek - Moves read-write file offset
SYNOPSIS
#include <sys/types.h> #include <unistd.h>
off_t lseek (
int filedes,
off_t offset,
int whence );
PARAMETERS
Specifies a file descriptor obtained from a successful open() or
fcntl() function. Specifies a value, in bytes, that is used in con‐
junction with the whence parameter to set the file pointer. A negative
value causes seeking in the reverse direction. The resulting file posi‐
tion may also be negative. Specifies how to interpret the offset
parameter in setting the file pointer associated with the filedes
parameter. Values for the whence parameter are: Sets the file pointer
to the value of the offset parameter. Sets the file pointer to its
current location plus the value of the offset parameter. Sets the file
pointer to the size of the file plus the value of the offset parameter.
DIFFERENCESalpha-32bits(5): 32 vs 64 bit Differences
When calling the lseek() system call for setting the current position
in a file, use the off_t type defined in types.h for the file offset.
Passing an int or long constant might work, but it is not portable and
is not guaranteed to continue to work.
EXAMPLES
The following example shows the correct use of lseek():
-------------------------------------------------------------------------
32-Bit Platform | AXP Platform
-----------------------------------+-------------------------------------
|
| #include <unistd.h>
| #include <unistd.h>
| long offset, pos;
| off_t offset, pos;
|
| pos = lseek(fd, offset, SEEK_SET);
| pos = lseek(fd, offset, SEEK_SET); pos = lseek(fd, 0L, SEEK_CUR);
| pos = lseek(fd, (off_t)0, SEEK_CUR);
|
-------------------------------------------------------------------------
RELATED INFORMATION
Functions: lseek(2)CATEGORY INDEXalpha-32bits(5)
delim off
Digital UNIX Diffs - lseek(5)