Printing a C "string" with write(f)ln

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Feb 9 23:20:03 PST 2016


On Tuesday, 9 February 2016 at 22:39:14 UTC, Gary Willoughby 
wrote:
> On Tuesday, 9 February 2016 at 17:02:28 UTC, Jakob Ovrum wrote:
>> to!string behaving like that was a poor design choice[1]. 
>> Please use fromStringz.
>>
>> [1] https://github.com/D-Programming-Language/phobos/pull/1607
>
> It's not a poor design choice. It ensures the string is handled 
> by the D GC instead of the C side freeing it. `fromStringz` and 
> `to!(String)` are for different cases.

You clearly didn't read the discussion in the link. And, when 
copying is desired, I'll take fromStringz(cstr).idup over 
to!string any day.



More information about the Digitalmars-d-learn mailing list