NAME

fseek, ftell, rewind - reposition a stream

SYNOPSIS

#include <stdio_p.h>

int fseek (stream, offset, ptrname)
FILE *stream;
long offset;
int ptrname;

long ftell (stream)
FILE *stream;

rewind(stream)
FILE *streaml

DESCRIPTION

fseek sets the positon 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.

fseek undoes any effects of ungetc(3P).

rewind(stream) is equivalent to fseek(stream, 0L, 0).

After fseek or rewind, the next operation on an update file may be either input or output (see argument type for fopen(3P) ).

ftell returns the current value of the offset relative to the beginning of the file associated with the named stream. The offset is measured in bytes on PARASITE 1.0, PARASITE-FS 1.0, UNIX 3.0, and UNIX/RT; on some other systems, it is a magic cookie and is the only foolproof way to obtain an offset for fseek.

SEE ALSO

lseek(2P) , fopen(3P).

DIAGNOSTICS

fseek returns non-zero for improper seeks, otherwise zero.