FAT | RFS | XFS | ZFS

ftell()

PROTOTYPE

#include <stdio.h>

long ftell(FILE *file);

DESCRIPTION

ftell() gets the current file offset for the open regular file identified by file.

If successful, ftell() returns the number of bytes from the beginning of the file to the current position. Otherwise, it returns -1.

ERROR CODES

EBADF file is not the handle of an open file.
EISDIR file refers to a directory.

EXAMPLE

long pos;
FILE *file;

...

/*-----------------------------------------------------------------*/
/* Get current position of the stream.                             */
/*-----------------------------------------------------------------*/
pos = ftell(file);
if (pos == -1L)
{
  perror("error getting file's current position");
  return -1;
}