Article View: gnu.g++.bug
Article #594problem with cin return
From: Wayne Winder
Date: Fri, 17 Nov 1989 18:58
Date: Fri, 17 Nov 1989 18:58
35 lines
1320 bytes
1320 bytes
Running g++ (1.35.0) on a sun 3, OS3.5
I report this since I'm sure this used to work,
but doesn't with this version. The following
program gets into an infinite loop when the
standard input is redirected from a file which
does not terminate with a <CR>.
-----------------
#include <stream.h>
main()
{
char buf[100];
int i = 0;
while (cin >> buf) i++;
cout << "i: " << i << "\n";
}
-----------------
It also does not behave as expected when the
standard input is pushed in via <ctrl-D>.
The return from "cin >> buf" appears to be the
cin reference, which correctly shows eof to be
true when the (redirected) input file does not
end with <CR>. This correctly returns a <NULL>
when the input file has a terminating <CR>.
Wayne E. Winder
Northwest Lab for Integrated Systems
University of Washington
Technical Details
Message-ID:
<8911171858.AA23884@toutle.cs.washington.edu>Path:
arc1-ca.pugleaf.net!utzoo!yunexus!ists!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!TOUTLE.CS.WASHINGTON.EDU!wayneShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!yunexus!ists!jarvis.csri.toronto.edu!rutgers!ucsd!tut.cis.ohio-state.edu!TOUTLE.CS.WASHINGTON.EDU!wayne From: wayne@TOUTLE.CS.WASHINGTON.EDU (Wayne Winder) Newsgroups: gnu.g++.bug Subject: problem with cin return Message-ID: <8911171858.AA23884@toutle.cs.washington.edu> Date: 17 Nov 89 18:58:28 GMT Article-I.D.: toutle.8911171858.AA23884 Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 35