char* pointers between C and D
ryuukk_
ryuukk.dev at gmail.com
Mon Jul 25 09:36:05 UTC 2022
Here is the way to do it with `writefln` (i think)
```D
import std;
import core.stdc.string;
void main()
{
const(char)[] ch = "Hello World!";
const(char)[] ch2 = "abc";
const(char)* p;
p = &ch[0];
p++;
auto str = p[0 .. strlen(p)];
writefln("%s", str);
}
```
Note that i removed your `.dup` it is unecessary, string literals
needs `const(char)`
After looking at the doc, `writefln` needs a slice, so we just do
that and pass it
More information about the Digitalmars-d-learn
mailing list