D2 toStringz Return Type

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Nov 8 09:20:20 PST 2008


ore-sama wrote:
> Andrei Alexandrescu Wrote:
> 
>> ore-sama wrote:
>>> Uh... I used toStringz, but didn't know that it's return type is 
>>> const and that people have troubles with this :) AFAIK the only 
>>> function, writing to its sz argument is strtok, C libraries
>>> usually follow popular convention that input strings are "in".
>> strcpy sprintf strcat gets, off the top of my head. They are so bad
>> and dangerous, for some safer versions were introduced and are
>> universally recommended: strncpy snprintf strncat.
> 
> that's because they get char buffer, not sz, so they can't determine
> end of buffer scanning for null (strcat does, but it's still buffer).
> toStringz has nothing to do with these functions.

Good point.

Andrei



More information about the Digitalmars-d mailing list