Array access via pointer

Pelle pelle.mansson at gmail.com
Sun May 30 14:14:11 PDT 2010


On 05/30/2010 11:00 PM, Robert wrote:
> On 2010-05-30 22:16:55 +0200, Pelle <pelle.mansson at gmail.com> said:
>
>> &data[0] and &data are very different things, if you have a dynamic
>> array.
>
> Yes, that's what I found out too. What's the exact difference?
>

A dynamic array is a fat pointer with a length, approximately a struct 
with a pointer and a size_t. &data is the address of this structure, of 
type ubyte[]*, whereas &data[0], or data.ptr is a pointer to the first 
element, of type ubyte*. I hope this clarifies things :)


More information about the Digitalmars-d mailing list