2 ms·
strncpy()'s NUL-padding behaviour is the right thing for its niche, which is copying to fixed-length buffers such as the 14-character filenames in ancient files
by jomar 11y ago
strncpy()'s NUL-padding behaviour is the right thing for its niche, which is copying to fixed-length buffers such as the 14-character filenames in ancient filesystem directory entries. See http://stackoverflow.com/a/1454071 http://stackoverflow.com/a/1454071
That niche doesn't particularly exist anymore, so strncpy() isn't often a good fit for what people need these days. Hence they don't like strncpy(), but what they really mean is that they shouldn't have been considering strncpy() in the first place.
strncat() on the other hand... now that's a weird function!