Interfacing C programs: Pass D string to C function

Jonathan M Davis jmdavisProg at gmx.com
Sat Dec 14 14:48:24 PST 2013


On Friday, December 13, 2013 01:17:41 Jonathan M Davis wrote:
> or you could do something like
> 
> auto cstr = str.dup.ptr;

Wait. That was stupid of me. Don't do this. It'll give you a char*, but it 
won't be null-terminated. If you need char*, then use toUTFz!(char*) - though 
from what Mike's saying, it sounds like the problem was really your function 
prototype, which was supposed to take const char* rather than char*.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list