Seekg

In the C++ programming language, seekg is a function in the  library (part of the standard library) that allows you to seek to an arbitrary position in a file. This function is defined for ifstream class - for ofstream class there's a similar function seekp (this is to avoid conflicts in case of classes that derive both istream and ostream, such as iostream).

is the seeking direction. It is an object of type  that can take any of the following constant values:
 * is the new position in the stream buffer. This parameter is an object of type streampos.
 * is an integer value of type streamoff representing the offset in the stream's buffer. It is relative to the  parameter.
 * 1)  (offset from the beginning of the stream's buffer).
 * 2)  (offset from the current position in the stream's buffer).
 * 3)  (offset from the end of the stream's buffer).

Note: If you have previously got an end of file on the stream,  will not reset it but will return an error in many implementations. - use the  method to clear the end of file bit first. This is a relatively common mistake and if  is not performing as expected, it is wise to clear the fail bit, as shown below.