On Wednesday, 25 October 2017 at 00:35:29 UTC, Ali Çehreli wrote:
> char[] name = "/tmp/XXXXXX".dup;
remain valid. The actual issue is the missing '\0'. So,
consider toStringz in this case:
https://dlang.org/library/std/string/to_stringz.html
Thanks for your reply, but can you clarify exactly I should use
this?
char[] name = "/tmp/XXXXXX".toStringz;
gives
<src>(13): Error: cannot implicitly convert expression
`toStringz("/tmp/XXXXXX")` of type `immutable(char)*` to `char[]`
So I tried:
char[] name = "/tmp/XXXXXX".toStringz.dup;
which gives
<src>(13): Error: template object.dup cannot deduce function from
argument types !()(immutable(char)*), candidates are:
/usr/include/dmd/druntime/import/object.d(1943):
object.dup(T : V[K], K, V)(T aa)
/usr/include/dmd/druntime/import/object.d(1979):
object.dup(T : V[K], K, V)(T* aa)
/usr/include/dmd/druntime/import/object.d(3764):
object.dup(T)(T[] a) if (!is(const(T) : T))
/usr/include/dmd/druntime/import/object.d(3780):
object.dup(T)(const(T)[] a) if (is(const(T) : T))
And:
char[] name = "/tmp/XXXXXX".dup.toStringz;
gives the error <src>(13): Error: cannot implicitly convert
expression `toStringz(dup("/tmp/XXXXXX"))` of type
`immutable(char)*` to `char[]`
So I'm not sure what to do?!