Each file object has two integer values associated with it. They are:
- get pointer
- put pointer
The get pointer specifies a location from which the current reading operation is initiated. The put pointer specifies a location from which the current writing operation is initiated.
We can use these pointers to move through the files while reading or writing.
Following are the functions for manipulation of file pointers:
- seekg() moves get pointer to specified location
- seekp() moves put pointer to specified location
- tellg() gives the current position of the get pointer
- tellp() gives the current position of the put pointer
The first prototype for seekg() and seekp() are:
The second prototype for seekg() and seekp() are:
seekg ( position, direction);
seekp (position, direction);
The direction can be of three formats: ios::beg, ios::cur, ios::end