FTELL(3) Library Functions Manual FTELL(3)

ftell ftelloreturn a file offset in a stream

#include <stdio.h>

long int ftell(FILE *stream);
off_t ftello(FILE *stream);

The ftell() function obtains the current value of the file-position indicator for the stream pointed to by stream .

The ftello() function is identical to ftell() except that the return value is of type off_t.

Upon successful completion, ftell() and ftello() return the current value of the file-position indicator for the stream measured in bytes from the beginning of the file.

Otherwise, ftell() and ftello() return -1, cast to and off_t respectively, and set to indicate the error.

The ftell() and ftello() functions will fail if:

The file descriptor underlying stream is not an open file descriptor.
For ftell() , the current file offset cannot be represented correctly in an object of type long .
For ftello() , the current file offset cannot be represented correctly in an object of type off_t .
The file descriptor underlying stream is associated with a pipe or FIFO.

None.

None.

None.

fgetpos(3) , fopen(3) , fseek(3) , ftello() , lseek(3) , <stdio.h> , and the XNS specification description of ftell() .

Derived from Issue 1 of the SVID.

February 1997 posix.fail