readln with buffer fails
dcrepid via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Oct 29 18:13:19 PDT 2014
On Wednesday, 29 October 2014 at 23:28:07 UTC, Justin Whear wrote:
> Part of what readln does is *modify* the slice itself, not just
> the
> pointed-to
> characters. In particular it alters the length member so that
> you know
> how much
> input was actually read. This is also why the rvalue reference
> shouldn't
> work.
> Remember, D chose not to repeat C's mistake of relying on null
> terminators.
Nice, thanks for that. I wasn't aware the .length member was
changed, but I just verified it myself by surrounding the call
with some debug output. Sure enough, its length is 4096 before
the call, and a different length after (depending on what was
input).
More information about the Digitalmars-d-learn
mailing list