istream bug

Alexandre Oliva aoliva@redhat.com
Thu Jan 4 11:28:00 GMT 2001


On Jan  4, 2001, Robert Schweikert <rjschwei@mindspring.com> wrote:

> When using the "ios::nocreate" opening mode on an istream the file
> pointer moves to the end of the file which causes the read with the
> stream operator ">>" to fail.

Wouldn't it be the case that you failed to specify that the stream is
for input?  By passing ios::nocreate, you overrode the default
argument that is ios::input (sp?), so you should have ORed
ios::nocreate to ios::input to get an input stream.  Yes, it's
counter-intuitive, but that's the way it is implemented.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me


More information about the Gcc mailing list