ftell() in C is used to find out the position of file pointer in the file with respect to starting of the file. Syntax of ftell() is:
long ftell(FILE *pointer)
Consider below C program. The file taken in the example contains the following data :
“Someone over there is calling you. We are going for work. Take care of yourself.” (without the quotes)
When the fscanf statement is executed word “Someone” is stored in string and the pointer is moved beyond “Someone”. Therefore ftell(fp) returns 7 as length of “someone” is 6.
Output : Assuming test.txt contains “Someone over there ….”.
This article is contributed by Hardik Gaur. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.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.
- Difference between Increment and Decrement Operators
- Problem in comparing Floating point numbers and how to compare them correctly?
- exit(0) vs exit(1) in C/C++ with Examples
- Predefined Macros in C with Examples
- How to create GUI in C programming using GTK Toolkit
- ctype.h(<cctype>) library in C/C++ with Examples
- Slack Bytes in Structures : Explained with Example
- Difference between Iterators and Pointers in C/C++ with Examples
- C program to count number of vowels and consonants in a String
- Nested Loops in C with Examples
- Hello World Program : First program while learning Programming
- Difference between Argument and Parameter in C/C++ with Examples
- Implicit Type Conversion in C with Examples
- <cfloat> float.h in C/C++ with Examples