basic_istream::tellg

报告在读取流的当前位置。

pos_type tellg( );

返回值

流中的当前新位置。

备注

失败 如果为 false,成员函数返回 ->pubseekoffrdbuf (0,cur英寸)。 否则,返回 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;
}

Enter:basic_istream_tellg.txt

0123456789

程序输出

0 0
1 1

要求

页眉: <istream>

命名空间: std

请参见

参考

basic_istream 类

iostream 编程

iostreams 约定