Simple Array Question

Silv3r 14908832 at sun.ac.za
Fri Jun 1 12:24:08 PDT 2007


When using multi-dimensional arrays I easily get confused as to the order of the notation. But why does args[i][] equal args[][i] (code below)? I assume args[i][] is the more correct version as only args[i][0] gives the correct results?

-Silv3r

-----------------------------------------------------------------------
import std.stdio;

void main(char[][] args)
{
 writefln("args.length = %d\n", args.length);
 for (int i = 0; i < args.length; i++)
 {
  if(args[i][] == args[][i]) // why does args[i][] equal args[][i]?
   writefln("Why does this work? [%d] = '%s'", i, args[i][]);
  writefln("<%s>,<%s>", args[i][0],args[0][i]);
 }
}
-----------------------------------------------------------------------


More information about the Digitalmars-d-learn mailing list