ftell

Returns the current value of the file position indicator for a stream.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  long ftell (
     FILE   *fp);
  

Parameters

fp

(IN) Points to the file.

Return Values

If successful, returns the current read/write position of the file specified by fp. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not valid.

33

ESPIPE

The file descriptor underlying stream is associated with a pipe, a socket, or a FIFO.

81

EOVERFLOW

The current file offset cannot be represented correctly in an object of type long.

Remarks

The ftell function returns the current read/write position of the file specified by fp. This position defines the character to be read or written by the next I/O operation on the file. You can use the value returned by ftell in a subsequent call to fseek in order to set the file to the same position.

See Also