fseek(3s) DG/UX 4.30 fseek(3s)
NAME
fseek, rewind, fgetpos, fsetpos, ftell - reposition a file
pointer in a stream
SYNOPSIS
#include <stdio.h>
int fseek (stream, offset, ptrname)
FILE *stream;
long offset;
int ptrname;
void rewind (stream)
FILE *stream;
int fgetpos (stream, pos)
FILE *stream;
fpost *pos;
int fsetpos (stream, pos)
FILE *stream;
fpost *pos;
long ftell (stream)
FILE *stream;
DESCRIPTION
Fseek 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.
Rewind(stream) is equivalent to fseek(stream, 0L, 0), except
that no value is returned.
Fgetpos stores the current value of the file position
indicator for stream in the object pointed to by pos. This
value can be used in a subsequent call to fsetpos to
reposition the stream to this position.
Fsetpos sets the file position indicator for stream to the
value of the object pointed to by pos; this value must have
been obtained by an earlier call to fgetpos.
Fseek, rewind, and fsetpos undo any effects of ungetc(3S).
After fseek, rewind, or fsetpos the next operation on a file
opened for update may be either input or output.
Ftell returns the offset of the current byte relative to the
beginning of the file associated with the named stream.
Licensed material--property of copyright holder(s) Page 1
fseek(3s) DG/UX 4.30 fseek(3s)
SEE ALSO
lseek(2), fopen(3S), popen(3S), stdio(3S), ungetc(3S).
DIAGNOSTICS
fseek returns non-zero for improper seeks, otherwise zero.
An improper seek can be, for example, an fseek done on a
file that has not been opened via fopen; in particular,
fseek may not be used on a terminal, or on a file opened via
popen(3S). If the file has not been opened, errno is set to
EBADF along with a non-zero return value.
Fgetpos and fsetpos return zero if successful, otherwise
non-zero.
WARNING
Although on the UNIX system an offset returned by ftell is
measured in bytes, and it is permissible to seek to
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.
Licensed material--property of copyright holder(s) Page 2