Reading input lines

Jarrett Billingsley kb3ctd2 at yahoo.com
Mon Jan 22 19:29:33 PST 2007


"Bill Lear" <rael at see.sig.com> wrote in message 
news:m33b621rvp.fsf at pppp.zopyra.com...
>I am trying to read lines from stdin and echo them to stdout.
>
> I have come up with this:
>
> import std.stdio;
> import std.cstream;
> import std.string;
>
> void main () {
>    while (!din.eof()) {
>        char[] line = din.readLine();
>        if (line == null) continue;
>        writefln("%s", line);
>    }
> }
>
> but am confused why I would need to check for null.  Is there
> a better way to do this?

Do you?  I took out the null check and it works fine, unless you're getting 
errors on Linux or something. 





More information about the Digitalmars-d mailing list