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::ios_base::seekdir(3) C++ Standard Libary std::ios_base::seekdir(3)

std::ios_base::seekdir - std::ios_base::seekdir


typedef /*implementation defined*/ seekdir;
static constexpr seekdir beg = /*implementation defined*/


static constexpr seekdir end = /*implementation defined*/


static constexpr seekdir cur = /*implementation defined*/


Specifies file seeking direction type. The following constants are defined:


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

// Run this code


#include <iostream>
#include <string>
#include <sstream>


int main()
{
std::istringstream in("Hello, World!");
std::string word1, word2, word3, word4, word5;


in >> word1;
in.seekg(0, std::ios_base::beg); // <- rewind
in >> word2;
in.seekg(1, std::ios_base::cur); // -> seek from cur pos toward the end
in >> word3;
in.seekg(-6, std::ios_base::cur); // <- seek from cur pos (end) toward begin
in >> word4;
in.seekg(-6, std::ios_base::end); // <- seek from end toward begin
in >> word5;


std::cout << "word1 = " << word1 << '\n'
<< "word2 = " << word2 << '\n'
<< "word3 = " << word3 << '\n'
<< "word4 = " << word4 << '\n'
<< "word5 = " << word5 << '\n';
}


word1 = Hello,
word2 = Hello,
word3 = World!
word4 = World!
word5 = World!


seekg sets the input position indicator
(public member function of std::basic_istream<CharT,Traits>)
seekp sets the output position indicator
(public member function of std::basic_ostream<CharT,Traits>)
pubseekoff invokes seekoff()
(public member function of std::basic_streambuf<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.