🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Wayne Winder Fri, 17 Nov 1989 18:58
problem with cin return
#594
Author: Wayne Winder
Date: Fri, 17 Nov 1989 18:58
35 lines
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads