Crazy stuff

Tower Ty tytower at hotmail.com.au
Sun Apr 27 14:04:07 PDT 2008


Simen Kjaeraas Wrote:

> On Sun, 27 Apr 2008 14:58:12 +0200, Tower Ty <tytower at hotmail.com.au>  
> wrote:
> 
> > I suppose I'm getting tired but this array stuff is just so bloody  
> > non-intuiitive
> >
> > I'm copying an array  of strings into another array of arrays of strings
> > char[][] array1
> > array1 has in it [ 1, 12/12/06, 0123456, Hubert, 340, 1240.00, 0.00 ]
> > and I want to accumulate it in ,
> > char[][][] array2
> > as a line in array2. Array1's contents will change on the next pass of  
> > the loop and I increase x by 1 and want to store it then in array2line2
> > So I try
> > array2[x]=array1;
> > or
> > array2[x]=array1[0..6]
> > or
> > array2[x]=array1[]
> > or Jesus I'm buggered if I know what to try next ,it could be anything
> >
> > array2[x]=array1.dup don't work either
> 
> This works on my confuser (DMD 2.013, DMD 1.029):
> 
>    string[] a = ["Hello", "World"];
>    string[][] b;
> 
>    b ~= a.dup;
> 
>    a[0] = "HAI";
>    a[1] = "WURLD!1";
> 
>    b ~= a.dup;
> 
>    writefln(b); // prints [[Hello,World],[HAI,WORLD!!!1]]
> 
> 
> Without the .dups, output is [[HAI,WORLD!!!1],[HAI,WORLD!!!1]].
> 
> -- Simen

Thanks -now to stick the hair back. Would never have thought of approaching it with append . Logically I just want to put it in a firm place with a defined index address.

Does not seem to be covered in the Tango book either.

So can you explain how you are using " string".
What are you importing to be able to use string?



More information about the Digitalmars-d-learn mailing list