std::basic_istream<CharT,Traits>::tellg (3) - Linux Manuals
std::basic_istream<CharT,Traits>::tellg: std::basic_istream<CharT,Traits>::tellg
Command to display std::basic_istream<CharT,Traits>::tellg
manual in Linux: $ man 3 std::basic_istream<CharT,Traits>::tellg
NAME
std::basic_istream<CharT,Traits>::tellg - std::basic_istream<CharT,Traits>::tellg
Synopsis
pos_type tellg();
Returns input position indicator of the current associated streambuf object.
Behaves as UnformattedInputFunction, except that gcount() is not affected. After constructing and checking the sentry object, if fail() == true, returns pos_type(-1). Otherwise, returns rdbuf()->pubseekoff(0, std::ios_base::cur, std::ios_base::in).
Parameters
(none)
Return value
The current position of the get pointer on success, pos_type(-1) on failure
Exceptions
failure if an error occurred (the error state flag is not goodbit) and exceptions() is set to throw for that state.
If an internal operation throws an exception, it is caught and badbit is set. If exceptions() is set for badbit, the exception is rethrown.
Example
// Run this code
#include <iostream>
#include <string>
#include <sstream>
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
See also
seekoff repositions the file position, using relative addressing
(virtual protected member function of std::basic_filebuf<CharT,Traits>)
[virtual]
seekoff 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>)
[virtual]
seekoff repositions the next pointer in the input sequence, output sequence, or both, using relative addressing
(virtual protected member function of std::strstreambuf)
[virtual]
sets the input position indicator
seekg (public member function)
returns the output position indicator
tellp (public member function of std::basic_ostream<CharT,Traits>)
sets the output position indicator
seekp (public member function of std::basic_ostream<CharT,Traits>)
Pages related to std::basic_istream<CharT,Traits>::tellg
- std::basic_istream<CharT,Traits>::basic_istream (3) - std::basic_istream<CharT,Traits>::basic_istream
- std::basic_istream<CharT,Traits>::gcount (3) - std::basic_istream<CharT,Traits>::gcount
- std::basic_istream<CharT,Traits>::get (3) - std::basic_istream<CharT,Traits>::get
- std::basic_istream<CharT,Traits>::getline (3) - std::basic_istream<CharT,Traits>::getline
- std::basic_istream<CharT,Traits>::ignore (3) - std::basic_istream<CharT,Traits>::ignore
- std::basic_istream<CharT,Traits>::operator= (3) - std::basic_istream<CharT,Traits>::operator=
- std::basic_istream<CharT,Traits>::operator>> (3) - std::basic_istream<CharT,Traits>::operator>>
- std::basic_istream<CharT,Traits>::peek (3) - std::basic_istream<CharT,Traits>::peek
- std::basic_istream<CharT,Traits>::putback (3) - std::basic_istream<CharT,Traits>::putback
- std::basic_istream<CharT,Traits>::read (3) - std::basic_istream<CharT,Traits>::read
- std::basic_istream<CharT,Traits>::readsome (3) - std::basic_istream<CharT,Traits>::readsome
- std::basic_istream<CharT,Traits>::seekg (3) - std::basic_istream<CharT,Traits>::seekg
- std::basic_istream<CharT,Traits>::sentry (3) - std::basic_istream<CharT,Traits>::sentry
- std::basic_istream<CharT,Traits>::swap (3) - std::basic_istream<CharT,Traits>::swap
- std::basic_istream<CharT,Traits>::sync (3) - std::basic_istream<CharT,Traits>::sync
- std::basic_istream<CharT,Traits>::unget (3) - std::basic_istream<CharT,Traits>::unget
- std::basic_istream<CharT,Traits>::~basic_istream (3) - std::basic_istream<CharT,Traits>::~basic_istream
- std::basic_istream (3) - std::basic_istream
- std::basic_istream_sentry (3)
- std::basic_istringstream (3) - std::basic_istringstream