"fast AND correct strncpy" not working by itself?
Posted Aug 28, 2003 15:44 UTC (Thu) by
dwheeler (subscriber, #1216)
In reply to:
"fast AND correct strncpy" not working by itself? by IkeTo
Parent article:
[PATCH] fast AND correct strncpy
Exactly right. strncpy _must_, by spec, \0 out the rest of the string.
Which means that, in most code, you don't really want strncpy();
it wastes time zero'ing out bytes you probably don't care about.
If you want limited-length string operations, I suggest using
the strlcpy() / strlcat() functions, which aren't in the official C
standard but ARE widely available.
(
Log in to post comments)