

#include <stdio.h> int fseek (FILE *f, long int offset, int type);
fseek repositions the stream associated with the FILE object
pointed to by f, as specified by the values of offset and
type. The type value must be one of SEEK_SET,
SEEK_CUR, or SEEK_END. (These constants are defined in
<stdio.h>.) Each of the type values refers to a specific
location in the file, as follows:
SEEK_SET refers to the start of the file.
SEEK_CUR refers to the current file position.
SEEK_END refers to the end of file.
The interpretation of the offset value depends on the value of
type and whether f identifies a text or binary stream.
For a binary stream, the offset value specifies the offset in characters
of the new position from the location identified by type. Because of
this ISO/ANSI requirement, fseek can be called for a binary stream only
when the "rel" access method is used. Note that the offset value
may be either positive or negative, but positioning before the start of the file
is not supported. See File positioning with fseek and ftell for the details of
positioning beyond the end of file.
When fseek is used with a text stream, two cases can be distinguished.
If the value of offset is 0, the file is repositioned to the location
identified by type. An offset value other than 0 is supported for
a text stream only if type is SEEK_SET. In this case,
offset must be a value previously returned by ftell for the same
stream, and fseek restores the file position at the time of that call.
Note that, in this case, the value in offset is an internal representation
of the file position and cannot be interpreted as a relative character number.
After a call to fseek on a stream that permits both reading and writing,
the next file operation may be input or output. (However, for an MVS PDS
member, you can switch from reading to writing only at the start of the file.)
fseek returns 0. If it fails, fseek returns a
nonzero value and stores an appropriate value in errno. See the list of
errno values in The errno Variable .
fseek on a text stream, characters
following the point of output may be erased from the file. This occurs when
trunc=yes is in effect. Therefore, when trunc=yes is in effect,
you are unable to return to a previous file position if output has been
performed before that point.
See Opening Files for more information on the trunc amparm.
fseek application because the
implementation of fseek varies from system to system and library to
library.
ftell.
ksearch, kseek, lseek, fsetpos, ftell
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.