Range violation error when reading from a file

Samir samir at aol.com
Fri Jun 21 01:29:00 UTC 2019


On Tuesday, 18 June 2019 at 09:42:41 UTC, aliak wrote:
> On Tuesday, 18 June 2019 at 01:15:54 UTC, Samir wrote:
>> On Monday, 17 June 2019 at 03:46:11 UTC, Norm wrote:
>>> That's because you're using write*ln*. So even though line is 
>>> empty, you still output a new line.
>>
>> Curious.  I am going to have to think about that for a bit as 
>> I don't quite understand.
>
> I mean this:
>
> $ dmd -run readfile.d
> 1)
> file.eof() == false
> line = "> line 1"
> writeln("lines 1" + \n);
> 2)
> file.eof() == false
> line = line 2
> writeln("line 2" + \n);
...snip...
> 6)
> file.eof() == false
> line = "" // empty since there're no lines left in file
> writeln("" + \n); <-- this is your blank line
> 7)
> file.eof() == true

Got it!  Now I see what you were saying.  Thanks for taking the 
time to provide a detailed explanation!


More information about the Digitalmars-d-learn mailing list