The tellg() function is used with input streams, and returns the current “get” position of the pointer in the stream. It has no parameters and returns a value of the member type pos_type, which is an integer data type representing the current position of the get stream pointer.
Returns: The current position of the get pointer on success, pos_type(-1) on failure.
After reading the word "geeksforgeeks" tellg() returns -1
Example 2 :
After reading the word "Hello," tellg() returns 6
tellg() does not report the size of the file, nor the offset from the beginning in bytes. It reports a token value which can later be used to seek to the same place, and nothing more. (It’s not even guaranteed that you can convert the type to an integral type)
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Read a record from a File in C++ using seekg() and tellg()
- Difference between user defined function and library function in C/C++
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- fma() function in C++
- div() function in C++
- exp() function C++
- log() function in C++
- fegetexceptflag() function in C/C++
- vswprintf() function in C/C++
- fegetenv() function in C/C++
- wctrans() function in C/C++
- wmemcpy() function in C/C++
- wcsncat() function in C/C++
- wcsncmp() function in C/C++
- wcsrtombs() function in C/C++
- wcstod() function in C/C++
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 Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.