readln() returns new line charater
Jeroen Bollen
jbinero at gmail.com
Sat Dec 28 09:23:29 PST 2013
On Saturday, 28 December 2013 at 17:15:17 UTC, Jakob Ovrum wrote:
> On Saturday, 28 December 2013 at 16:59:51 UTC, bearophile wrote:
>> void main() {
>> import std.stdio, std.string;
>> immutable txt = readln.chomp;
>> writeln(">", txt, "<");
>> }
>>
>>
>> Bye,
>> bearophile
>
> These examples are cute, but I think in real programs it's
> usually important to handle `stdin` being exhausted. With
> `readln`, such code is prone to go into an infinite loop.
>
> Of course in these same real programs, `byLine` is often the
> better choice anyway...
Usually if you're working with a console though the input stream
won't exhaust and thus the blocking 'readln' would be a better
option, no?
I'll just use the chomp method as that seems like the best option.
More information about the Digitalmars-d
mailing list