Formatted input from text file

IK istvan.karolyi at rocketmail.com
Tue Jun 19 07:17:16 PDT 2012


This program below fails if the file contains an empty line.
Why exactly does this happen?
Does ln get a mangled value when a line is empty?


     import std.format;
     import std.stdio;

     void main()
     {
         int[] test;

         foreach (ln; File("ints.txt").byLine)
             formattedRead(ln, "%(%d %)", &test);

         writefln("%(%d %)", test);
     }


std.conv.ConvException at c:\dmd2\windows\bin\..\..\src\phobos\std\conv.d(1779): 
Unexpected '
' when converting from type char[] to type int
----------------
4169C4
41684F
405E63
405BDF
405A06
405964
40573F
4055CE
40246B
4020CC
4083A0
4083DA
407FFB
41DB21
----------------




More information about the Digitalmars-d-learn mailing list