Go to the first, previous, next, last section, table of contents.

Repositioning an istream

Use these methods to control the current input position:

Method: streampos istream::tellg ()

Return the current read position, so that you can save it and return to it later with istream::seekg.

Method: istream& istream::seekg (streampos p)

Reset the input pointer (if the input device permits it) to p, usually the result of an earlier call to istream::tellg.

Method: istream& istream::seekg (streamoff offset, ios::seek_dir ref)

Reset the input pointer (if the input device permits it) to offset characters from the beginning of the input, the current position, or the end of input. Specify how to interpret offset with one of these values for the second argument:

ios::beg
Interpret loc as an absolute offset from the beginning of the file.
ios::cur
Interpret loc as an offset relative to the current output position.
ios::end
Interpret loc as an offset from the current end of the output stream.


Go to the first, previous, next, last section, table of contents.