Using "strcpy" to assign value to dynamic char array

pascal111 judas.the.messiah.111 at gmail.com
Wed Nov 3 10:38:45 UTC 2021


On Wednesday, 3 November 2021 at 02:38:56 UTC, Steven 
Schveighoffer wrote:
> 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

I started to change my mind about doing things in low level of 
classic C, I started to think get benefits of new features of D.



More information about the Digitalmars-d-learn mailing list