Standard C++ Library Reference ISO/IEC (VERSION3)
of type pos_type stores at least an fpos_t object.)
For a file opened for both reading and writing, both the input and output streams are positioned
in tandem. To switch between inserting and extracting, you must call either pubseekoff or
pubseekpos. Calls to pubseekoff (and hence to seekoff) have various limitations for
text streams, binary streams, and wide streams.
If the file pointer fp is a null pointer, the function fails. Otherwise, it endeavors to alter the
stream position by calling fseek(fp, off, way). If that function succeeds and the
resultant position fposn can be determined by calling fgetpos(fp, &fposn), the
function succeeds. If the function succeeds, it returns a value of type pos_type containing
fposn. Otherwise, it returns an invalid stream position.
basic_filebuf::seekpos
virtual pos_type seekpos(pos_type pos,
ios_base::openmode which =
ios_base::in | ios_base::out);
The protected virtual member function endeavors to alter the current positions for the controlled
streams. For an object of class basic_filebuf<Elem, Tr>, a stream position can be
represented by an object of type fpos_t, which stores an offset and any state information
needed to parse a wide stream. Offset zero designates the first element of the stream. (An object
of type pos_type stores at least an fpos_t object.)
For a file opened for both reading and writing, both the input and output streams are positioned
in tandem. To switch between inserting and extracting, you must call either pubseekoff or
pubseekpos. Calls to pubseekoff (and hence to seekoff) have various limitations for
text streams, binary streams, and wide streams.
For a wide stream, if any insertions have occured since the stream was opened, or since the last
call to streampos, the function calls overflow(). It also inserts any sequence needed to
restore the initial conversion state, by using the file conversion facet fac to call
fac.unshift as needed. Each element byte of type char thus produced is written to the
associated stream designated by the file pointer fp as if by successive calls of the form
fputc(byte, fp). If the call to fac.unshift or any write fails, the function does not
succeed.
If the file pointer fp is a null pointer, the function fails. Otherwise, it endeavors to alter the
stream position by calling fsetpos(fp, &fposn), where fposn is the fpos_t object
stored in pos. If that function succeeds, the function returns pos. Otherwise, it returns an
invalid stream position.