std::basic_ostream::seekp

From Cppreference

Jump to: navigation, search
basic_ostream& seekp( pos_type pos );

basic_ostream& seekp( off_type& off, std::ios_base::seekdir dir);

Sets output position indicator of the current associated streambuf object. In case of failure, calls setstate(std::ios_base::failbit).

1) sets the output position indicator to absolute (relative to the beginning of the file) value pos. Specifically calls rdbuf()->pubseekpos(pos, std::ios_base::out).

2) sets the output position indicator to position off, relative to position, defined by dir. Specifically rdbuf()->pubseekoff(off, dir, std::ios_base::out).

Contents

[edit] Parameters

pos - absolute position to set the output position indicator to.
off - relative position to set the output position indicator to.
dir - defines base position to apply the relative offset to. It can be one of the following constants:
Constant Explanation
beg the beginning of a stream
end the ending of a stream
cur the current position of stream position indicator

[edit] Return value

*this

[edit] Example

[edit] See also

tellp
returns the output position indicator
(public member function)
tellg
returns the input position indicator
(public member function of std::basic_istream)
seekg
sets the input position indicator
(public member function of std::basic_istream)