Article View: gnu.g++.lib.bug
Article #194Reading last thing from an istream
From: T.Day
Date: Sun, 26 Nov 1989 20:04
Date: Sun, 26 Nov 1989 20:04
28 lines
1022 bytes
1022 bytes
From: Tim Day <T.Day@uk.ac.ucl.cs>
// Bug or feature ? In libg++ 1.36 using g++ 1.36.1
// I'm think this behaved differently with libg++ 1.35. A 2.0ism ?
// The problem is that if the last integer is not followed by whitespace
// the istream will go bad... I'd expect this to happen only on a subsequent
// attempt to read
#include <stream.h>
main()
{ unlink("foo");
{ostream foo("foo",io_writeonly,a_create);
foo << 1 << " " << 2 << " " << 3;// No trailing whitespace after 3
}
{istream foo("foo",io_readonly,a_useonly);
int count=0,n;
while (foo >> n) {cerr << n << " ";count++;}
cerr << " : " << count << " integers read\n";
}
exit(0);
}
// Outputs :
// 1 2 : 2 integers read
Technical Details
Message-ID:
<473@ucl-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!ukc!kl-cs!nott-cs!ucl-cs!T.DayShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!mcsun!ukc!kl-cs!nott-cs!ucl-cs!T.Day From: T.Day@ucl-cs.UUCP Newsgroups: gnu.g++.lib.bug Subject: Reading last thing from an istream Message-ID: <473@ucl-cs.UUCP> Date: 26 Nov 89 20:04:45 GMT Sender: T.Day@ucl-cs.UUCP Lines: 28