String[] pointer to void* and back

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Sep 18 14:11:56 PDT 2014


On 09/18/2014 01:59 PM, seany wrote:

 >       string[] s = ["aa", "bb", "cc"];
 >       string []* ss;
 >       void * v;
 >
 >       ss = &s;
 >       v = cast(void*)s;

Not s, but its address should be assigned to v:

     v = cast(void*)&s;

Only then it will match its reverse operation:

 >       ss = cast(string[]*) v;
 >
 >       s = *ss;
 >
 >       writeln(s);

Ali



More information about the Digitalmars-d-learn mailing list