std::basic_istream::seekg

From Cppreference

Jump to: navigation, search
basic_istream& seekg( pos_type pos );

basic_istream& seekg( off_type& off, std::ios_base::seekdir dir);

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

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

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

Contents

[edit] Parameters

pos - absolute position to set the input position indicator to.
off - relative position to set the input 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

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