fseek(3) CLIX fseek(3)
NAME
fseek, rewind, ftell - Repositions a file pointer in a stream
LIBRARY
Standard C Library (libc.a)
SYNOPSIS
#include <stdio.h>
int fseek(
FILE *stream ,
long offset ,
int ptrname );
void rewind(
FILE *stream );
long ftell(
FILE *stream );
PARAMETERS
stream Points to a file.
offset Specifies the number of bytes from a specified location in the
file.
ptrname Specifies the position to begin I/O on a stream.
DESCRIPTION
The fseek() function sets the position of the next input or output
operation on the stream. The new position is at the signed distance
offset bytes from the beginning, from the current position, or from the
end of the file, according as ptrname has the value 0, 1, or 2.
Calling rewind(stream) is equivalent to calling fseek(stream,0,0), except
that no value is returned.
The fseek() and rewind() functions undo any effects of ungetc(). After
fseek() or rewind(), the next operation on a file opened for update may be
either input or output.
The ftell() function returns the offset of the current byte relative to
the beginning of the file associated with the named stream.
CAUTIONS
2/94 - Intergraph Corporation 1
fseek(3) CLIX fseek(3)
Although on the UNIX system an offset returned by ftell() is measured in
bytes, and it is permissible to seek positions relative to that offset,
portability to non-UNIX systems requires that an offset be used by fseek()
directly. Arithmetic may not meaningfully be performed on such an offset,
which is not necessarily measured in bytes.
RETURN VALUES
The fseek() function returns nonzero for improper seeks, or 0 otherwise.
An improper seek can be, for example, an fseek() done on a file that has
not been opened with fopen(); in particular, fseek() may not be used on a
terminal, or on a file opened with popen().
RELATED INFORMATION
Functions: lseek(2), fopen(3), popen(3), ungetc(3), stdio(3)
2 Intergraph Corporation - 2/94