Pointer to the file stream whose current position is to be retrieved
Read more about parameters of ftell in parameters section
The ftellfunction in C language Returns the current file position of the stream.
The ftell function obtains the current value of the file position indicator for the stream pointed to by stream. For binary streams, this is the number of bytes from the beginning of the file. For text streams, the numerical value may not be meaningful but can still be used with fseek to restore the position to the same position later.
The ftellfunction takes 1
parameter:
•
FILE * `stream`: Pointer to the file stream whose current position is to be retrieved
Returns the current file position of the specified file stream as a `long` value representing the number of bytes from the beginning of the file. Returns `-1L` on error.
The ftell function return value :
Returns the current value of the file position indicator if successful
On failure, it returns -1L and sets errno to indicate the error
Output
This example demonstrates how to use ftell to determine the size of a file. It seeks to the end of the file and then uses ftell to get the position, which is equivalent to the file size.