Read text file, line by line?

Robert Clipsham robert at octarineparrot.com
Tue Dec 13 06:08:14 PST 2011


On 13/12/2011 13:58, Iain S wrote:
> How would one achieve this in D2?  I have tried for a couple of hours
> now and have achieved nothing but stress.

import std.stdio;

void main() {
     foreach(line; File("myTextFile.txt").byLine()) {
         writefln(line);
     }
}

-- 
Robert
http://octarineparrot.com/


More information about the Digitalmars-d-learn mailing list