pointer array?
Daniel Kozak via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Jul 30 07:44:15 PDT 2014
V Wed, 30 Jul 2014 14:33:51 +0000
seany via Digitalmars-d-learn <digitalmars-d-learn at puremagic.com>
napsáno:
> In Ali's excllent book, somehow one thing has escaped my
> attention, and that it the mentioning of pointer arrays.
>
> Can pointers of any type of pointed variable be inserted in an
> int array? Using to!(int) perhaps? If not directly, then what
> else would achieve the same effect?
It depends on pointer size, for eg, on 64bit system with 64bit pointers
something like this should works:
long[] arr = (cast(long*)pointersArray.ptr)[0 .. pointersArray.length];
or
long[] arr = cast(long[])pointersArray; // but I am not sure if this is
OK
More information about the Digitalmars-d-learn
mailing list