www.digitalmars.com         C & C++   DMDScript  

D - Braindead re: row-wise & column-wise

reply Benji Smith <dlanguage xxagg.com> writes:
I'm getting the semantics of multidimensional arrays all messed up in my mind,
and I need someone to help clarify something for me.

When declaring an array of strings, you're e3ssentially declaring a
multi-dimensional array. But I always get my row-wise and my column-wise array
accessing messed up. So, if I declare an array like this...

char[][] strings = ["zero", "one", "two", "three"];

..and I want to get the "one" entry into a new string, which of these do I
use...

char[] x = strings[][1];
char[] x = strings[1][];
char[] x = strings[1];

I've been writing code exclusively in perl lately (a requirement for work (btw,
I HATE perl's variable prefixes, using $ to dereference scalars from   and %
structures, not to mention the {} required to dereference a hash value)), and
I'm having trouble remembering whether perl uses the same accessing order
(row-wise? column-wise?) as Java or C. It's like somebody whacked me in the head
with a stupid-stick.

--Benji Smith
Aug 29 2003
parent "Walter" <walter digitalmars.com> writes:
"Benji Smith" <dlanguage xxagg.com> wrote in message
news:binldj$1uka$1 digitaldaemon.com...
 I'm getting the semantics of multidimensional arrays all messed up in my

 and I need someone to help clarify something for me.

 When declaring an array of strings, you're e3ssentially declaring a
 multi-dimensional array. But I always get my row-wise and my column-wise

 accessing messed up. So, if I declare an array like this...

 char[][] strings = ["zero", "one", "two", "three"];

 ..and I want to get the "one" entry into a new string, which of these do I
 use...

 char[] x = strings[][1];
 char[] x = strings[1][];
 char[] x = strings[1];

The 3rd one.
Aug 29 2003