Array access via pointer

Robert robert.muench at
Sun May 30 12:43:16 PDT 2010

Hi, I hope some of you D gurus can help me getting my mind setup 
correct when using D arrays.

I have an array: data[1 .. 2048] of type ubyte

I'm interested in getting the addresse of the array and its data 
members. So I used:

writefln("adress data[%d] = %d", 0, &data);
writefln("adress data[%d] = %d", 2047, &data[2047]);

And got:

address data[0] = 18FE50
address data[2047] = 2607FF

Which is:

> 0x2607ff - 0x18fe50
ans = 0x000D09AF
ans = 854447

Shouldn't these addresses have a difference of 2047 bytes? Why do I get 
those strange addresses back?

Robert M. Münch

More information about the Digitalmars-d mailing list