On Wednesday, 7 May 2025 at 22:47:35 UTC, Andy Valencia wrote:

So about fromStringz...

```d
import std.string : fromStringz;
import core.stdc.time : ctime;

void
main() {
    string s = fromStringz(ctime(null));
}
```

Like that?

tst44.d(6): Error: cannot implicitly convert expression `fromStringz(ctime(null))` of type `char[]` to `string`

Still seeking...

`fromStringz` is giving you a slice of a `char*`, typed `char[]`.

`string` is `immutable(char)[]`, so you can't assign `char[]` to it.

You could:

* change the type of `s` to `char[]`
* call `.idup` on the array returned from `fromStringz` to allocate a `string`
* use `std.conv.to`

Reply via email to