共用方式為


basic_streambuf::seekoff

A protected virtual member function that tries to alter the current positions for the controlled streams.

virtual pos_type seekoff(
    off_type _Off,
    ios_base::seekdir _Way,
    ios_base::openmode _Which = ios_base::in | ios_base::out
);

Parameters

  • _Off
    The position to seek for relative to _Way.

  • _Way
    The starting point for offset operations. See seekdir for possible values.

  • _Which
    Specifies the mode for the pointer position. The default is to allow you to modify the read and write positions.

Return Value

Returns the new position or an invalid stream position ( seekoff (_Off, _Way, _Which) ).

Remarks

The new position is determined as follows:

  • If _Way == ios_base::beg, the new position is the beginning of the stream plus _Off.

  • If _Way == ios_base::cur, the new position is the current stream position plus _Off.

  • If _Way == ios_base::end, the new position is the end of the stream plus _Off.

Typically, if which & ios_base::in is nonzero, the input stream is affected, and if which & ios_base::out is nonzero, the output stream is affected. Actual use of this parameter varies among derived stream buffers, however.

If the function succeeds in altering the stream position or positions, it returns the resulting stream position or one of the resulting stream positions. Otherwise, it returns an invalid stream position. The default behavior is to return an invalid stream position.

Requirements

Header: <streambuf>

Namespace: std

See Also

Reference

basic_streambuf Class

iostream Programming

iostreams Conventions