readln() returns new line charater

Vladimir Panteleev vladimir at thecybershadow.net
Sat Dec 28 09:13:02 PST 2013


On Saturday, 28 December 2013 at 17:07:58 UTC, Andrei 
Alexandrescu wrote:
> On 12/28/13 8:50 AM, Jeroen Bollen wrote:
>> On Saturday, 28 December 2013 at 16:49:15 UTC, Jeroen Bollen 
>> wrote:
>>> Why is when you do readln() the newline character (\n) gets 
>>> read too?
>>> Wouldn't it make more sense for that character to be stripped 
>>> off?
>>
>> I just want to add to this, that it makes it really annoying 
>> to work
>> with the command line, as you kinda have to strip off the last 
>> character
>> and thus cannot make the string immutable.
>
> Try stdin.byLine, which by default strips the newline.

stdin.byLine can't strip \r\n unless you specify that as the line 
terminator, in which case it can't split by \n.


More information about the Digitalmars-d mailing list