fseek(3s)
NAME
fseek, ftell, rewind − reposition a file pointer in a stream
SYNTAX
#include <stdio.h>
int fseek(stream, offset, ptrname)
FILE *stream;
long offset;
int ptrname;
long ftell(stream)
FILE *stream;
void rewind(stream)
FILE *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, the current position, or the end of the file, according as ptrname has the value 0, 1, or 2.
The fseek function undoes any effects of ungetc(3s).
The ftell function returns the current value of the offset relative to the beginning of the file associated with the named stream. It is measured in bytes and is the only foolproof way to obtain an offset for fseek.
The rewind( function is equivalent to fseek ( stream , 0L, 0), except that no value is returned.
DIAGNOSTICS
The fseek function returns −1 for improper seeks, otherwise 0.