The fseek() function sets the file-position indicator for the stream pointed to by stream. The fseeko() function is identical to fseek() except for the type of offset.
The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence, whose values are
defined in <stdio.h> as follows:
-
SEEK_SET
- Set position equal to offset bytes.
-
SEEK_CUR
- Set position to current location plus offset.
-
SEEK_END
- Set position to EOF plus offset.
If the stream is to be used with wide character input/output functions, offset must either be 0 or a value returned by an earlier call to ftell(3C) on the same stream and whence must be SEEK_SET.
A successful call to fseek() clears the end-of-file indicator for the stream and undoes any effects of ungetc(3C) and ungetwc(3C) on the same stream. After
an fseek() call, the next operation on an update stream may be either input or output.
If the most recent operation, other than ftell(3C), on a given stream is fflush(3C), the file offset in the underlying open file description will be adjusted to reflect the location specified by fseek().
The fseek() function allows the file-position indicator to be set beyond the end of existing data in the file. If data is later written at this point, subsequent reads of data in
the gap will return bytes with the value 0 until data is actually written into the gap.
The value of the file offset returned by fseek() on devices which are incapable of seeking is undefined.
If the stream is writable and buffered data had not been written to the underlying file, fseek() will cause the unwritten data to be written to the file and mark the st_ctime and st_mtime fields of the file for update.
|