www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Re: expected array behaviour

reply Mike James <foo bar.com> writes:
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=-
Jan 01 2009
parent "Jarrett Billingsley" <jarrett.billingsley gmail.com> writes:
On Thu, Jan 1, 2009 at 7:10 PM, Mike James <foo bar.com> 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 the data over.
Jan 01 2009