_llseek

2.x

  LONG _llseek(hf, lOffset, nOrigin)    
  HFILE hf; /* file handle */
  LONG lOffset; /* number of bytes to move */
  int nOrigin; /* position to move from */

The _llseek function repositions the pointer in a previously opened file.

Parameters

hf

Identifies the file.

lOffset

Specifies the number of bytes the pointer is to be moved.

nOrigin

Specifies the starting position and direction of the pointer. This parameter must be one of the following values:

Value Meaning

0 Move the file pointer lOffset bytes from the beginning of the file.
1 Move the file pointer lOffset bytes from its current position.
2 Move the file pointer lOffset bytes from the end of the file.

Return Value

The return value specifies the new offset, in bytes, of the pointer from the beginning of the file, if the function is successful. Otherwise, the return value is HFILE_ERROR.

Comments

When a file is initially opened, the file pointer is positioned at the beginning of the file. The _llseek function permits random access to a file's contents by moving the pointer an arbitrary amount without reading data.

Example

The following example uses the _llseek function to move the file pointer to the end of an existing file:

HFILE hfAppendFile;

/* Open the write file. */

hfAppendFile = _lopen("append.txt", WRITE);



/* Move to the end of the file. */

if (_llseek(hfAppendFile, 0L, 2) == -1) {
    ErrorHandler();
}

See Also

_lopen