Accessing array elements with a pointer-to-array
Stephen Tashiro
tashiro at zianet.com
Fri Jan 26 11:38:39 UTC 2024
On Thursday, 25 January 2024 at 20:36:49 UTC, Kagamin wrote:
> On Thursday, 25 January 2024 at 20:11:05 UTC, Stephen Tashiro
> wrote:
>> void main()
>> {
>> ulong [3][2] static_array = [ [0,1,2],[3,4,5] ];
>> static_array[2][1] = 6;
>> }
>
> The static array has length 2, so index 2 is out of bounds,
> must be 0 or 1.
I understand that the index 2 is out of bounds in an array of 2
things. I'm confused about the notation for multidimensional
arrays. I thought that the notation uint[m][n] is read from
right to left, so it denotes n arrays of m things in each array.
So I expected that static_array[k][j] would denotes the kth
element of the jth array.
More information about the Digitalmars-d-learn
mailing list