Format
#include <stdio.h> long int ftell(FILE *stream);
Language Level: ANSI, POSIX, XPG4
ftell finds the current position of the file associated with stream.
For a fixed-length binary file, the value returned by ftell is an
offset relative to the beginning of the stream.
Note: For buffered text streams, ftell returns an incorrect file position if the file contains new-line characters instead of carriage-return line-feed combinations. Your file would only contain new-line characters if you previously used it as a binary stream. To avoid this problem, either continue to process the file as a binary stream, or use unbuffered I/O operations.
Return Value
ftell returns the current file position. On error, ftell
returns -1L and sets errno to a nonzero value.
![]()
fseek -- Reposition File Position
fgetpos -- Get File Position
fopen -- Open Files
fsetpos -- Set File Position
<stdio.h>