Range violation error when reading from a file
aliak
something at something.com
Mon Jun 17 11:25:01 UTC 2019
On Monday, 17 June 2019 at 00:22:23 UTC, Samir wrote:
>
> Also, if I run the program below with the same file, I don't
> get any range violation errors:
Ya, writeln will not access individual elements of a range if
there aren't any. So no violations occur.
> HOWEVER, the output is interesting. There IS a blank line
> between the last line and the prompt:
That's because you're using write*ln*. So even though line is
empty, you still output a new line.
> Any suggestions on how to rectify?
You can do:
if (!line.length) {
continue;
}
Inside your while loop after the call to strip.
More information about the Digitalmars-d-learn
mailing list