Comment Re: strncpy never made sense (Score 1) 18
strncpy() was not intended for null-terminated strings at all. It should have been named copy_null_padded_buffer(). Then its operation would have made sense to almost anyone. People wouldn't have minded the longer name much either, because hardly anybody uses null-padded buffers in modern software.
Note that a null-padded buffer that is completely full doesn't have any nulls in it at all. That's why strncpy() doesn't necessarily add a null termination. It also fills the entire destination buffer with nulls after the end of a short copy, which can be very inefficient when used with null-terminated strings.
TL;DR: don't use strncpy(). It doesn't do what anybody thinks it does.