添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Get position of the get pointer .
Returns the position of the get pointer . The get pointer determines the next location to be read in the buffer associated to the input stream. Parameters. The function returns an object of type streampos describing the current position of the get pointer in the stream. Example.
// read a file into memory #include <iostream> #include <fstream> using namespace std; int main () { int length; char * buffer; ifstream is; is.open ("test.txt", ios::binary ); // get length of file: is.seekg (0, ios::end); length = is.tellg(); is.seekg (0, ios::beg); // allocate memory: buffer = new char [length]; // read data as a block: is.read (buffer,length); is.close(); cout.write (buffer,length); return 0; In this example tellg is used to get the offset of the last character in the stream, determining thus the size of the file. Basic template member declaration ( basic_istream<charT,traits> ):
typedef traits::pos_type pos_type; pos_type tellg ();