Thread: clearing error flags on streams

  1. #1
    Registered User
    Join Date
    Oct 2005

    clearing error flags on streams

    I had to interface with zlib so I downloaded a thing called gzstream from

    The problem is that when I try to reset the EOF flags on an igzstream object like so
    is.seekg(0, ios::beg);
    the EOF flag is cleared but any subsequent calls on operator>>() don't work.

    I looked through the code and the derived igzstream class does not seem to be overloading any of the flags from its parent class. And I'm guessing this should not be an issue (or I'm most probably wrong). I'd appreciate it if anyone can point out how to fix this.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Portland, OR
    I looked at the code. The stream does not support seeking. It silently fails. Notice that there are zero calls to gzseek() -- it can't possibly work.

    When you seek to the beginning, apparently the base iostream is clearing the flags, but the world is not in a good state. The library seems broken for allowing something that doesn't actually work.

    The workaround is to close and reopen the stream to read it again.
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Clearing Terminal
    By mrginger in forum C Programming
    Replies: 3
    Last Post: 04-15-2009, 11:58 AM
  2. Writing to two streams: va_arg issues
    By dwks in forum C Programming
    Replies: 2
    Last Post: 09-26-2007, 10:14 AM
  3. bit clearing problem
    By Buckshot in forum C++ Programming
    Replies: 3
    Last Post: 07-19-2005, 07:36 PM
  4. Clearing the screen
    By Shadow in forum C Programming
    Replies: 4
    Last Post: 05-23-2002, 01:40 PM
  5. Independent streams of pseudo random number generator
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 11-15-2001, 05:32 AM