Variable lengh arrays of fixed length arrays

Derek Parnell derek at nomail.afraid.org
Thu Aug 3 18:06:02 PDT 2006


What am I not understanding about these beasties...?

This fails to compile ...

 void main()
 {
  char[9][] sstore;  // A dynamic array of 9-char strings.
  char[9] astr;      // A single 9-char string.

  // Extend the dynamic array.
  sstore.length = sstore.length + 1; 

  // Copy the 9-char string to the last entry.
  sstore[$-1] = astr;  // **FAILS** 
 }

The compiler message is ...

test.d(10): cannot assign to static array (sstore)[cast(int)((__dollar) -
1u)]

In my mind, 'sstore' is *not* a static array. It is a dynamic array that
contains static arrays.

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocrity!"
4/08/2006 11:03:26 AM



More information about the Digitalmars-d-learn mailing list