次の方法で共有


basic_istream::tellg

ストリームの現在の読み取り位置を報告します。

pos_type tellg( );

戻り値

ストリームの現在の位置。

解説

失敗 が false の場合は、メンバー関数は rdbuf ->pubseekoff (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;
}

入力: basic_istream_tellg.txt

0123456789

プログラムの出力

0 0
1 1

必要条件

ヘッダー: の <istream>

名前空間: std

参照

関連項目

basic_istream クラス

iostream プログラミング

iostreams の規則