D array to void* and back

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Aug 3 14:37:25 PDT 2015


On 08/03/2015 02:33 PM, ref2401 wrote:
> On Monday, 3 August 2015 at 21:28:29 UTC, Ali Çehreli wrote:
>
>> But you still need to communicate how many elements there are in the
>> array. (I used literal 3).
>
> Yes I do. I hope there is a neat way to pass array's length too.
>

Not possible in C. :( Common methods:

* An array-like struct

* A separate parameter for the number of elements

* A sentinel value at the end of the array (e.g. '\0' for strings or 
NULL for arrays of pointers to objects, -1 where it is not valid as an 
element value, etc.)

Ali



More information about the Digitalmars-d-learn mailing list