Using "strcpy" to assign value to dynamic char array

pascal111 judas.the.messiah.111 at gmail.com
Mon Nov 1 19:56:13 UTC 2021


I know that I can use the next syntax to assign new value to char 
dynamic array, and the new value isn't in same length of the 
current value of the array:

{

char[] s="xyz".dup;

s="Hello World!".dup;

writeln(s);
}

Result:

Hello World!

=====================

But what if I want to use "strcpy" function to assign that new 
value to the array that the problem is that the array won't take 
more than its first initializing value length:

{

char[] s="xyz".dup;

strcpy(&s[0], "Hello World!");

writeln(s);

}

Result:

Hel



More information about the Digitalmars-d-learn mailing list