Listing 1 A rewind manipulator for istream

/* rewind.h vers 0.9
   defines istream manipulator rewind
   that "rewinds" input stream to
   beginning of file and clear state
   (to reset eof flag)

   copyright 1994 Paul Hepworth

   Permission is granted for everyone
   to include this code in his/her
   programs without restriction.
*/
#if !defined_REWIND_H
  #define_REWIND_H

  #if !defined _IOSTREAM_H
   #include <iostream.h>
  #endif

class rewind_type
   {
   friend istream& operator>>(istream& is,
                         const rewind_type);
   };

const static rewind_type rewind;

inline istream& operator>>(istream& is,
                      const rewind_type)
    {
    is.seekg(0);
    is.clear();
    return is;
    }
#endif