basic_istream::tellg
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

basic_istream::tellg 

Reports the current read position in the stream.


pos_type tellg( );

The current position in the stream.

If fail is false, the member function returns rdbuf -> pubseekoff(0, cur, in). Otherwise, it returns pos_type(-1).

// basic_istream_tellg.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>

int main()
{
    using namespace std;
    ifstream file;
    char c;
    streamoff i;

    file.open("basic_istream_tellg.txt");
    i = file.tellg();
    file >> c;
    cout << c << " " << i << endl;

    i = file.tellg();
    file >> c;
    cout << c << " " << i << endl;
}

Header: <istream>

Show:
© 2016 Microsoft