File Pointers The c++ I/O system supports four functions for setting a file pointer to any desired position inside the file or to get the current file pointer. These allow programmer to have control over a position in the file where the read or write operation takes place.
FUNCTION MEMBER OF CLASS seekg() ifstream tellg() ifstream seekp() ofstream tellp() ofstream There are two pointers in the class fstream – the put pointer used for writing and the get pointer used for reading
seekg() Moves get file pointer(input)to a specified location. Syntax: seekg( offset, refposition); tellg() Gives the current position of the get pointer. Syntax: pos_type tellg ();
seekp() Moves put file pointer(output)to a specified location. Syntax: seekp( offset, refposition); tellp() Gives the current position of the put pointer. Syntax: pos_type tellp ();