| I/O manipulators | ||||
| Print functions(C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++20) | ||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
(C++23) | ||||
(C++23) | ||||
(C++23) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
(C++98/26*) | ||||
| Synchronized Output | ||||
(C++20) | ||||
| Types | ||||
| Error category interface | ||||
(C++11) | ||||
(C++11) |
| Global objects | ||||
| Member functions | ||||
(C++11) | ||||
| Formatted input | ||||
| Unformatted input | ||||
| Positioning | ||||
basic_istream::tellg | ||||
| Miscellaneous | ||||
(C++11) | ||||
| Member classes | ||||
| Non-member functions | ||||
pos_type tellg(); | ||
Returns input position indicator of the current associatedstreambuf object.
Behaves asUnformattedInputFunction, except thatgcount() is not affected. After constructing and checking the sentry object, iffail()==true, returnspos_type(-1). Otherwise, returnsrdbuf()->pubseekoff(0,std::ios_base::cur,std::ios_base::in).
Contents |
(none)
The current position of the get pointer on success,pos_type(-1) on failure.
If an internal operation throws an exception, it is caught andbadbit is set. Ifexceptions() is set forbadbit, the exception is rethrown.
#include <iostream>#include <sstream>#include <string> int main(){std::string str="Hello, world";std::istringstream in(str);std::string word; in>> word;std::cout<<"After reading the word\""<< word<<"\" tellg() returns "<< in.tellg()<<'\n';}
Output:
After reading the word "Hello," tellg() returns 6
[virtual] | repositions the file position, using relative addressing (virtual protected member function of std::basic_filebuf<CharT,Traits>)[edit] |
[virtual] | repositions the next pointer in the input sequence, output sequence, or both, using relative addressing (virtual protected member function of std::basic_stringbuf<CharT,Traits,Allocator>)[edit] |
[virtual] | repositions the next pointer in the input sequence, output sequence, or both, using relative addressing (virtual protected member function of std::strstreambuf)[edit] |
| sets the input position indicator (public member function)[edit] | |
| returns the output position indicator (public member function of std::basic_ostream<CharT,Traits>)[edit] | |
| sets the output position indicator (public member function of std::basic_ostream<CharT,Traits>)[edit] |