The put pointer determines the location in the output sequence where the next output operation is going to take place.
Parameters
- pos
- The new position in the stream buffer. This parameter is an integral value of type streampos.
- off
- Integral value of type streamoff representing the offset to be applied relative to an absolute position specified in the dir parameter.
- dir
- Seeking direction. It is an object of type ios_base::seekdir that specifies an absolute position from where the offset parameter off is applied. It can take any of the following member constant values:
value offset is relative to... ios_base::beg beginning of the stream buffer ios_base::cur current position in the stream buffer ios_base::end end of the stream buffer
Return Value
The function returns *this.Errors are signaled by modifying the internal state flags:
| flag | error |
|---|---|
| eofbit | - |
| failbit | The parameter(s) describe a position that could not be reached. |
| badbit | An error other than the above happened. |
Additionaly, in any of these cases, if the appropriate flag has been set with member function ios::exceptions, an exception of type ios_base::failure is thrown.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
In this example, seekp is used to move the put pointer back to a position 7 characters before the end of the first output operation. The final content of the file shall be:
This is a sample
Basic template member declaration
( basic_ostream<charT,traits> )| 1 2 3 4 |
|
See also
| ostream::tellp | Get position of put pointer (public member function) |
| istream::seekg | Set position of the get pointer (public member function) |
