ftell() in C with example
ftell() in C is used to find out the position of the file pointer in the file with respect to starting of the file.
The syntax of ftell() is:
long ftell(FILE *stream);
- stream: It is the pointer to the file stream.
- It returns a long integer value as the current position in the file.
- It returns -1 if an error occurs.
Example of ftell()
The below C program demonstrates the use of ftell() function.
* fp =
Suppose the file g4g.txt contains the following data:
Someone over there is calling you. We are going for work. Take care of yourself.
ftell(fp) returns 7. As the length of “someone” is 7 and the character indices are from 0 to 6.
If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!