access violation With dll?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jul 16 12:32:32 PDT 2015


On Thursday, 16 July 2015 at 17:28:52 UTC, jklp wrote:
> Also i guess that the dll returns a null terminated string so 
> the result has to be
> read like this:
>
> ---
> import std.string;
> printf("%s\n", fromStringz(STUFF.ptr));
> ---

That's not needed with printf, since it works with null 
terminated strings natively (it is itself a C function). Good 
advice for using writef though, or you can also just 
`to!string(cstr)` to get one.

> Otherwise you'll get a random output after the 'HELLO WORLD'.
> (wait maybe the console will automatically cut... ?)

the console won't, it'll generally spew trash.


More information about the Digitalmars-d-learn mailing list