Home

fseeko

fseeko is a function in the C standard library used to set the file position indicator for a given stream using a potentially large offset. It is designed to support large files by using the off_t type for the offset, rather than a long int.

The prototype is int fseeko(FILE *stream, off_t offset, int whence); The offset is interpreted according to the

Compared with fseek, fseeko uses off_t for the offset, enabling repositioning within files that exceed the range

Portability and availability vary by platform. fseeko is defined in POSIX and is widely supported on modern

Usage scenarios include working with large data files, binary formats, or file-based databases where offsets exceed

whence
parameter,
which
can
be
SEEK_SET,
SEEK_CUR,
or
SEEK_END,
similar
to
fseek.
On
success,
fseeko
returns
0;
on
error,
it
returns
a
nonzero
value
and
sets
errno
to
indicate
the
error.
of
long.
The
corresponding
function
to
query
the
current
position
is
ftello,
which
returns
an
off_t
representing
the
current
file
offset.
Unix-like
systems
and
many
C
libraries.
Some
environments
may
provide
alternative
or
legacy
variants
such
as
fseek
for
small
offsets,
or
platform-specific
64-bit
variants
like
fseeko64
or
ftello64.
When
targeting
very
large
files
on
platforms
without
fseeko,
developers
may
need
to
use
those
alternatives
or
rely
on
off_t
width.
32-bit
ranges.
As
with
fseek,
error
handling
should
consider
that
the
stream
must
be
seekable,
the
offset
must
be
valid,
and
the
operation
must
succeed
for
subsequent
I/O
to
proceed
correctly.