toStringz

fnimmutable(char) * toStringz(scope const(char)[] s) @trusted pure nothrow

Parameters

sA D-style string.

Returns

A C-style null-terminated string equivalent to s. s

must not contain embedded '\0''s as any C function will treat the first '\0' that it sees as the end of the string. If s.empty is true, then a string containing only '\0' is returned.

Important

Note

When passing a char* to a C function, and the C

function keeps it around for any reason, make sure that you keep a reference to it in your D code. Otherwise, it may become invalid during a garbage collection cycle and cause a nasty bug when the C code tries to use it.