> Correct on strcpy_s versus strncpy. Strncpy has the possibility of making a
> new bad situation while preventing another. You can easily end up with a
> string that is guaranteed to "run wild" if you strcpy it.

I personally have always preferred strlcpy to strncpy or strcpy_s, since
strlcpy is basically an "always-safe" copy function that doesn't have the
defects of strcpy_s (does nothing if the dest is too small, instead of
copying as much as it safely can) or strncpy (doesn't always null-terminate
the result; and always touches every byte of the dest area, which can be a
massive time-waster for large dest buffers).

The only problem with strlcpy is that it's not supported on many platforms,
any more than strcpy_s is...

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: GET IBM-MAIN INFO
Search the archives at http://bama.ua.edu/archives/ibm-main.html

Reply via email to