How to place char* of stringZ to ubyte[]?
bearophile
bearophileHUGS at lycos.com
Mon Oct 29 10:51:55 PDT 2012
denizzzka:
> immutable ubyte[] valueBin = cast(immutable(ubyte[]))
> toStringz(s); // s is string type
>
> Error: e2ir: cannot cast toStringz(s) of type immutable(char)*
> to type immutable(ubyte[])
One way to do it:
import std.stdio;
void main() {
string s = "hello";
auto valueBin = cast(immutable ubyte[])s.dup;
writeln(valueBin);
}
But what are you trying to do?
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list