On 9/11/10 3:00 PM, shd wrote:
Hello,
I'm having a problem in passing a value to char* expecting function
in D 2.0. Already tried:

to!(char*)("my string");

but it seems like there (Phobos) is no template like this. Then,
tried:

cast(char*)to!(char[])("my string")

which looked ok, but i think it's not a proper way to do that. Most
strings converted this way works properly, but once:

char* string1 = cast(char*)to!(char[])("my string 1");
char* string2 = cast(char*)to!(char[])("my string 2");

resulted:
string1 = "my string 1"
string2 = "my string 1my string 2"

I can't manage this problem, could You hint me?


Use std.string.toStringz to convert a D string to a C null-terminated one.

This asymmetry (no to!(char*)(string)) has been discussed once, but I can't remember the reason why it was not implemented right now.

Reply via email to