Home

ftello

ftello is a function in the C standard library (POSIX) that returns the current file position indicator for a given stream. The value represents the offset, in bytes, from the beginning of the file and is returned as an off_t type. It serves as a large-file–capable alternative to ftell, which historically uses a long int and may be unable to represent large offsets on some platforms.

Compared with ftell, ftello uses the off_t offset type, allowing it to represent larger file positions on

Return value and errors: On success, ftello returns the current offset as an off_t value. On error,

Usage notes: To reposition within a file, programs commonly pair ftello with fseeko, or use ftello to

See also: ftell, fseek, fseeko, off_t, fgetpos.

systems
that
support
large
files.
On
some
platforms,
off_t
may
be
64
bits,
enabling
offsets
beyond
2
GB
or
4
GB
depending
on
architecture.
Because
ftello
only
reads
the
current
position,
it
is
often
used
in
conjunction
with
fseeko,
the
counterpart
that
moves
the
file
position
using
an
off_t
offset.
it
returns
(off_t)
-1
and
sets
errno
to
indicate
the
error.
Common
error
conditions
include
EBADF
if
the
stream
is
not
a
valid
FILE*,
ESPIPE
if
the
stream
is
not
seekable
(for
example,
a
pipe),
and
other
stream-related
errors.
obtain
the
position
and
then
adjust
it
with
fseeko
as
needed.
For
portable
code
that
must
handle
large
files,
ftello/fseeko
are
preferred
over
ftell/fseek,
especially
when
_FILE_OFFSET_BITS
is
configured
for
64-bit
offsets.