Udostępnij za pośrednictwem


basic_istream::tellg

Reports the current read position in the stream.

pos_type tellg( );

Return Value

The current position in the stream.

Remarks

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

Example

// 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;
}

Input: basic_istream_tellg.txt

0123456789

Program Output

0 0
1 1

Requirements

Header: <istream>

Namespace: std

See Also

Reference

basic_istream Class

iostream Programming

iostreams Conventions

Other Resources

basic_istream Members