Using "strcpy" to assign value to dynamic char array

Steven Schveighoffer schveiguy at gmail.com
Wed Nov 3 02:38:56 UTC 2021


On 11/1/21 9:03 PM, pascal111 wrote:
> On Monday, 1 November 2021 at 21:32:21 UTC, Ali Çehreli wrote:

>> Joking aside
...
> 
> This function seems smart and flexible and higher than my current level, 
> I'll study it.

Please please, do NOT study this code. It is bad all around. Ali should 
know better ;)

He is joking with the code posted, it should not be used in any real 
code ever. Not only is it corrupting memory, it may not work as expected 
in all cases (and will randomly fail).

Please learn first how memory works before writing the low-level bits of 
arrays!

As a beginner, I suggest studying what a buffer overrun is, and why it 
is bad.

-Steve


More information about the Digitalmars-d-learn mailing list