Re: expected array behaviour

2009-01-01 Thread John Reimer
Hello Jarrett, On Thu, Jan 1, 2009 at 5:55 PM, Mike James wrote: I have a function that uses 2 array strings defined similar to this... const char[] array1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char[] array2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; If I make a change to a char in array1 it also changes t

Re: expected array behaviour

2009-01-01 Thread John Reimer
Hello Jarrett, If you want to modify the contents of string literals, like you're doing here, put a .dup on them. char[] array1 = "ABCD".dup; Again, modifying the contents of string literals is illegal and the results are undefined. Oh, right. I missed that. -JJR

Re: expected array behaviour

2009-01-01 Thread Jarrett Billingsley
On Thu, Jan 1, 2009 at 7:10 PM, Mike James wrote: > Got it - so I should do this... > > const char[] array1= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > char[] array2 = new char[array1.length]; Just "char[] array2 = array1.dup;" .dup duplicates the array by creating a new array the same length and copying

Re: expected array behaviour

2009-01-01 Thread Mike James
Got it - so I should do this... const char[] array1= "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char[] array2 = new char[array1.length]; and then copy the contents of array1 into array2. Regards, -=mike=-

Re: expected array behaviour

2009-01-01 Thread Jarrett Billingsley
On Thu, Jan 1, 2009 at 6:56 PM, Mike James wrote: > Hi John, > > I am using D1.038, dsss and Tango. > > I've written a quick example but this one is even stranger... > > > > module main; > > import tango.io.Stdout; > > int main() { >func1(); >func2(

Re: expected array behaviour

2009-01-01 Thread Mike James
Forgot to mention - Windows XP. Regards, -=mike=-

Re: expected array behaviour

2009-01-01 Thread Mike James
Hi John, I am using D1.038, dsss and Tango. I've written a quick example but this one is even stranger... module main; import tango.io.Stdout; int main() { func1(); func2(); return 0; } void func1() { char[] array1 = "ABCD"; char[

Re: expected array behaviour

2009-01-01 Thread Jarrett Billingsley
On Thu, Jan 1, 2009 at 5:55 PM, Mike James wrote: > I have a function that uses 2 array strings defined similar to this... > > const char[] array1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > char[] array2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; > > If I make a change to a char in array1 it also changes the same in

Re: expected array behaviour

2009-01-01 Thread John Reimer
Hello Mike, I have a function that uses 2 array strings defined similar to this... const char[] array1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char[] array2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; If I make a change to a char in array1 it also changes the same in array2. But if I define the arrays as follows

expected array behaviour

2009-01-01 Thread Mike James
I have a function that uses 2 array strings defined similar to this... const char[] array1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; char[] array2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; If I make a change to a char in array1 it also changes the same in array2. But if I define the arrays as follows... const char

Re: dynamic array of strings

2009-01-01 Thread Gide Nwawudu
On Tue, 30 Dec 2008 10:56:08 -0500, Michael P. wrote: >Jarrett Billingsley Wrote: > >> On Mon, Dec 29, 2008 at 10:36 PM, Michael P. wrote: >> > import std.stdio; >> > import std.cstream; >> > void main() >> > { >> > char[][] names; >> > char[] currentName; >> > while( true ) >> > { >> >d