C string to D without memory allocation?

Jakob Ovrum via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Dec 20 21:57:42 PST 2015


On Monday, 21 December 2015 at 05:43:04 UTC, Rikki Cattermole 
wrote:
> On 21/12/15 6:41 PM, Shriramana Sharma wrote:
>> Rikki Cattermole wrote:
>>
>>> string myCString = cast(string)ptr[0 .. strLen];
>>
>> Thanks but does this require that one doesn't attempt to 
>> append to the
>> returned string using ~= or such? In which case it is not 
>> safe, right?
>
> Correct, ~= should only be used by GC controlled memory. Which 
> this is not.

This is just plain wrong. No idea where you got this from.


More information about the Digitalmars-d-learn mailing list