basic_istream::tellg
報表資料流中目前的讀取位置。
pos_type tellg( );
傳回值
在資料流中的目前位置。
備註
如果 失敗 為 false,成員函式傳回 rdbuf - > pubseekoff(0, cur, in)。 否則,會傳回 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