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
|