GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::basic_ostream::seekp(3) C++ Standard Libary std::basic_ostream::seekp(3)

std::basic_ostream::seekp - std::basic_ostream::seekp


basic_ostream& seekp( pos_type pos ); (1)
basic_ostream& seekp( off_type off, std::ios_base::seekdir dir ); (2)


Sets the output position indicator of the current associated streambuf object.


Behaves as UnformattedOutputFunction (except without actually (since C++11)
performing output). After constructing and checking the sentry object,


1) sets the output position indicator to absolute (relative to the beginning of the
file) value pos by calling rdbuf()->pubseekpos(pos, std::ios_base::out). If the call
returns (pos_type)-1, executes setstate(failbit).
2) sets the output position indicator to offset off relative to dir by calling
rdbuf()->pubseekoff(off, dir, std::ios_base::out). If the call returns (pos_type)-1,
executes setstate(failbit).


pos - absolute position to set the output position indicator to.
off - relative position (positive or negative) to set the output position indicator
to.
defines base position to apply the relative offset to. It can be one of the
following constants:


dir - Constant Explanation
beg the beginning of a stream
end the ending of a stream
cur the current position of stream position indicator


*this


1-2) May throw std::ios_base::failure in case of failure, if exceptions() & failbit
!= 0.

// Run this code


#include <sstream>
#include <iostream>


int main()
{
std::ostringstream os("hello, world");
os.seekp(7);
os << 'W';
os.seekp(0, std::ios_base::end);
os << '!';
os.seekp(0);
os << 'H';
std::cout << os.str() << '\n';
}


Hello, World!


Defect reports


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
LWG 2341 C++98 two overloads behaved differently on failure made consistent


tellp returns the output position indicator
(public member function)
tellg returns the input position indicator
(public member function of std::basic_istream<CharT,Traits>)
seekg sets the input position indicator
(public member function of std::basic_istream<CharT,Traits>)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.