Using "strcpy" to assign value to dynamic char array
judas.the.messiah.111 at gmail.com
Mon Nov 1 20:49:53 UTC 2021
On Monday, 1 November 2021 at 20:15:14 UTC, Steven Schveighoffer
> On 11/1/21 3:56 PM, pascal111 wrote:
>> 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, "Hello World!");
> Don't do this, you just corrupted memory! You wrote 13 bytes
> into a memory location that contains 3.
> Use `.dup`, it does the equivalent of `strcpy`.
> Can you share why you want to use `strcpy` here?
Yes, I'm practicing doing things in low level style like standard
More information about the Digitalmars-d-learn