Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)
Guardian Native C Library Calls (f) fseek(3)
NAME
fseek - Repositions the file pointer of a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
int fseek(
FILE ∗∗stream,
long int offset,
int whence);
PARAMETERS
stream Specifies the I/O stream.
offset Determines the position of the next operation.
whence Determines the value for the file pointer associated with the stream parameter.
DESCRIPTION
The fseek() function sets the position of the next input or output operation on the I/O stream
specified by the stream parameter. The position of the next operation is determined by the offset
parameter, which can be either positive or negative.
The fseek() function sets the file pointer associated with the specified stream as follows:
• If the whence parameter is SEEK_SET, the pointer is set to the value of the offset
parameter.
• If the whence parameter is SEEK_CUR, the pointer is set to its current location plus the
value of the offset parameter.
• If the whence parameter is SEEK_END, the pointer is set to the size of the file plus the
value of the offset parameter.
The fseek() function fails if attempted on a file that was not opened with the fopen( ) function.
In particular, the fseek() function cannot be used on a terminal or on a file opened with the
popen( ) function.
A successful call to the fseek() function clears the End-of-File indicator for the stream and
undoes any effects of the ungetc() function on the same stream. After a call to the fseek() func-
tion, the next operation on an update stream may be either input or output.
If the stream is writable, and buffered data was not written to the underlying file, the fseek()
function causes the unwritten data to be written to the file and marks the st_ctime and st_mtime
fields of the file for update.
If the most recent operation (ignoring any ftell() operations) on a given stream was fflush(), then
the fseek() function causes the file offset in the underlying open file descriptor to be adjusted to
reflect the location specified by the fseek() function.
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 (zero) until data is actually written into the gap. The fseek() function does not,
by itself, extend the size of a file.
527192-007 Hewlett-Packard Company 2−95