1 2 3 4 5 6 7 8 9

File Positioning

*

Both the istream and ostream classes have functions for positioning the character pointer within the stream, these functions only work if the stream is connected to a disk file
For the ostream class we have the following three functions:

ostream& seekp (streampos);
ostream& seekp (streamoff, seek_dir);
streampos tellp ();

The streampos type is an absolute position within the stream, while the streamoff type is an offset from a reference position
The possible reference positions (values of type
seek_dir) are:

beg- beginning of the file
cur - current position in the file
end- end of the file

These functions work in essentially the same way as the stdio functions

*

1. 2. 3.

*

*

* * *

*

23 March, 1998

Page 6