D2 toStringz Return Type

ore-sama spam at here.lot
Sat Nov 8 07:54:13 PST 2008


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.



More information about the Digitalmars-d mailing list