| re: istringstream: str() only works once?
"Brandon" <bcr07548@creighton.edu> wrote in message
news:24f6b708.0406231105.688237e4@posting.google.c om...[color=blue][color=green]
> > What happens was that when you read the first integer from the stream[/color][/color]
you[color=blue][color=green]
> > hit the end of the stream, and so put your stream in an end of file[/color][/color]
state.[color=blue][color=green]
> > Once this happens, to any stream, nothing more will work on the stream[/color][/color]
until[color=blue][color=green]
> > you clear the end of file state. Use the clear() method to do this.[/color]
>
> I hadn't really thought about that but it makes perfect sense. It
> does seem like a fairly bad design though. As you said, once you hit
> the end of the stream, nothing more will work. That makes perfect
> sense for methods like get(), read(), and extraction but if you are
> trying to switch the string that it is using, you obviously won't be
> at the end of the stream anymore (unless you give it give it "" of
> course.)[/color]
It gets worse. Even closing a file and then opening a new one doesn't reset
a streams state. So an error on a previous file will stop a new file working
if you use the same variable.
I agree it seems nonsensical, apparently the situation with file streams is
being reviewed.
john |