File Position Pointers
To retrieve data sequentially from a file, programs normally start reading from the beginning of the file and read all the data consecutively until the desired data is found. It might be necessary to process the file sequentially several times (from the beginning of the file) during the execution of a program. Both
ostream provide member functions for repositioning the file-position pointer (the byte number of the next byte in the file to be read or written). These member functions are seekg (“seek get”) for
istream and seekp (“seek put”) for
istream object has a get pointer, which indicates the byte number in the file from which the next input is to occur, and each
ostream object has a put pointer ...