Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ 3.0r4 - <b>istream::seekg</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
istream::seekg

Usage

   #include <iostream.hpp>
   istream &istream::seekg(streampos);
   istream &istream::seekg(streamoff, relative_to);

   // iostream.hpp has - typedef long streampos, streamoff

Description

   Positions the get pointer of the associated streambuf. In the case of a
   file  based ostream, the action is similar to that of the stdio fseek()
   function.  Positioning is discussed further in the section describing
   classes  streambuf and filebuf.

   The absolute form (seekg(pos)) is to be interpreted as seekg(pos,
   ios::beg), that is relative to the start of the streambuf.

   The value used as an argument to seekg should have been one previously
   obtained from the complementary member function tellg(). In general, it
   should not be calculated, except that the particular value streampos(0)
   is  safe.

   In the case of relative seeks (e.g. seekg(0, end)) the seekoff value zero
   is  safe, but other values should be treated with caution. Remember that
   under DOS it is normal to convert newline characters to CR/LF pairs
   before they are sent to an actual output device, and to convert CR/LF
   pairs  to newline characters on input.

Example 

   ifstream ifs("input.dat");
   ...;
   streampos pos = ifs.tellg()

   ifs.seekg(0);                   // position at start of file
   int status = ifs.get();     // read status for example
   ifs.seekg(pos)                  // back to where we were

Return Value

   Returns a reference to the istream object for which it was called.





Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson