Read Complete File to Array of Lines
Paul
phshaffer at gmail.com
Fri May 11 13:40:21 PDT 2012
On Friday, 11 May 2012 at 18:02:54 UTC, Jesse Phillips wrote:
> On Friday, 11 May 2012 at 15:00:18 UTC, Paul wrote:
>> I would like to read a complete file in one statement and then
>> process it line by line.
>>
>> foreach (line; MyFile)
>> etc.
>>
>> Is it possible to read a file into and array of lines?
>> Thanks
>
> Something like:
>
> import std.file;
> import std.string;
>
> void main() {
> foreach(line; readText("file.in").splitLines()) ...
> }
Thanks Jesse.
I'm finding that I can't just substitute args[1] for a text
string. Is there a clever way to use args[] in place of your
"file.in"?
More information about the Digitalmars-d-learn
mailing list