Calling a C Function with C-style Strings
Ali Çehreli
acehreli at yahoo.com
Sat Nov 30 10:58:30 PST 2013
On 11/30/2013 07:58 AM, Dicebot wrote:
> char[] name = "alpha".dup;
> mktemp(name.ptr);
>
> D literals are zero-terminated so toStringz is only needed if you want
> to pass to C function slice of literal or some runtime input.
However, I doubt that .dup copies that '\0' character. Although the
literal has the termination, we are in slice land beyond that literal so
the termination must somehow be ensured.
Ali
More information about the Digitalmars-d-learn
mailing list