Using "strcpy" to assign value to dynamic char array

Imperatorn johan_forsberg_86 at hotmail.com
Wed Nov 3 17:20:17 UTC 2021


On Wednesday, 3 November 2021 at 10:38:45 UTC, pascal111 wrote:
> On Wednesday, 3 November 2021 at 02:38:56 UTC, Steven 
> Schveighoffer wrote:
>> On 11/1/21 9:03 PM, pascal111 wrote:
>>> [...]
>>
>>>> [...]
>> ...
>>> [...]
>>
>> 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.

Good, you will be much happier ☀️


More information about the Digitalmars-d-learn mailing list