Reading a line from stdin
spir
denis.spir at gmail.com
Wed Mar 16 03:20:43 PDT 2011
On 03/16/2011 06:41 AM, Jesse Phillips wrote:
> Ali Çehreli Wrote:
>
>> Right? Is there a better way that I am missing?
>>
>> Thank you,
>> Ali
>
> No better way, the stated reason IIRC is that it is easier to remove the new line then to append it back on.
May be stated, but it is very wrong! I guess:
s = s ~ '\n';
versus
if ((str[$-1] == '\n') || (str[$-1] == '\r')) {
str = str[0..$-1];
if ((str[$-1] == '\n') || (str[$-1] == '\r')) {
str = str[0..$-1];
}
}
And it's not what programmers want in most cases, anyway. Actually, when does
one need it?
Denis
--
_________________
vita es estrany
spir.wikidot.com
More information about the Digitalmars-d-learn
mailing list