std::basic_filebuf<CharT,Traits>::seekoff (3) - Linux Man Pages
virtual pos_type seekoff( off_type off,
std::ios_base::openmode which = std::ios_base::in | std::ios_base::out );
Repositions the file pointer, if possible, to the position that corresponds to exactly off characters from beginning, end, or current position of the file (depending on the value of dir.
If the associated file is not open (is_open()==false, fails immediately.
If the multibyte character encoding is state-dependent (codecvt::encoding() returned -1) or variable-length (codecvt::encoding() returned 0) and the offset off is not 0, fails immediately: this function cannot determine the number of bytes that correspond to off characters.
If dir is not std::basic_ios::cur or the offset off is not 0, and the most resent operation done on this filebuf object was output (that is, either the put buffer is not empty, or the most recently called function was overflow()), then calls std::codecvt::unshift to determine the unshift sequence necessary, and writes that sequence to the file by calling overflow().
Then converts the argument dir to a value whence of type int as follows:
value of dir value of whence
Then, if the character encoding is fixed-width (codecvt::encoding() returns some positive number width, moves the file pointer as if by std::fseek(file, width*off, whence).
Otherwise, moves the file pointer as if by std::fseek(file, 0, whence).
The openmode argument, required by the base class function signature, is usually ignored, because std::basic_filebuf maintains only one file position.
off - relative position to set the position indicator to.
dir - beg the beginning of a stream
which - Constant Explanation
A newly constructed object of type pos_type which stores the resulting file position, or pos_type(off_type(-1)) on failure.
seekoff() is called by std::basic_streambuf::pubseekoff, which is called by std::basic_istream::seekg, std::basic_ostream::seekp, std::basic_istream::tellg, and std::basic_ostream::tellp
// Run this code