Reading till the end of standard input
    Ali Cehreli 
    acehreli at yahoo.com
       
    Sun Sep 13 00:13:57 PDT 2009
    
    
  
I am using dmd v2.032 and trying to read int values from the standard input:
import std.cstream;
void main()
{
    while (!din.eof()) {
        int value;
        din.readf(&value);
        if (!din.eof()) {
            dout.writefln("read: ", value);
        }
    }
}
1) If I
- start the program in bash under Linux
- enter a few values
- press Ctrl-D to end the input,
that program gets stuck in the loop; is this a bug? (I will open a bug if you agree.)
2) I know that there is no need to read past the end of the stream to put it into EOF. Is that right? If so, the check within the while loop is unnecessary, right?
Thank you,
Ali
    
    
More information about the Digitalmars-d-learn
mailing list