String[] pointer to void* and back
seany via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Sep 18 14:35:49 PDT 2014
Yes, thank you, I corrected that.
However, if this v is a member of a class, like
import std.stdio;
import std.conv;
import core.vararg;
struct S
{
void *v;
}
class C
{
S* sx = new S;
void dothings()
{
string[] ss = ["1", "2", "4"];
string[] *s;
void *vv;
s = &ss;
vv = s;
sx.v = vv;
}
}
void main() {
C c = new C;
c.dothings();
writeln("done");
string[]* sh;
sh = cast(string[]*)c.sx.v;
writeln(sh); // upto this, works, the same pointer as
set in
// c.dothings(), checked with write
instructions
string[] si = *sh;
writeln(si);
}
and then casted back, then i notice that it does not work.
Wondering why.
More information about the Digitalmars-d-learn
mailing list