Problem with std.string.strip(): Can't use result in format routine
Ky-Anh Huynh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Sep 5 07:25:36 PDT 2017
On Tuesday, 5 September 2017 at 13:56:20 UTC, Andrea Fontana
wrote:
>> I used `lines(stdin)` as in
>> https://dlang.org/phobos/std_stdio.html#.lines . My source
>> code is here
>>
>> https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L47 .
>>
>> Thanks for your support.
>
> I think formattedRead is consuming your string.
Great catch. You're right. Thanks a lot.
`strip()` returns a slice. I use another reference variable to
save them and it's fine now.
[code]
auto line_st = line.strip();
auto line_st2 = line_st;
....
writefln("Stripped lined is %s", line_st2); // works fine
[/code]
More information about the Digitalmars-d-learn
mailing list