ftell

Purpose

Gets the position of the file pointer in a file.

Format

pos = ftell(fh)
Parameters:

fh (scalar) – file handle of a file opened with fopen().

Returns:

pos (scalar) – current position of the file pointer in a file.

Remarks

The ftell() function returns the position of the file pointer in terms of bytes from the beginning of the file. The call may fail if the file buffer needs to be flushed (see fflush()).

If an error occurs, ftell() returns -1. You can call fstrerror() to find out what the error was.

If you pass ftell() the handle of a file opened with open (i.e., a data set or matrix file), your program will terminate with a fatal error.

See also

Functions fopen(), fseek()