You know, I didn't believe you until I saw it in the man page
myself... Why doesn't it?
Despite its name, strncpy is not designed to produce strings, but
rather to produce fixed width records, arrays of characters, in
which the absence of a null character simply means that all
available characters are used. This avoids wasting space for a
redundant null character when the fixed width of the record is
well-known.
An example is the directory file format on some older operating
systems, which has a fixed width record holding (say) 11 characters:
A B C D E F G H J K L
if all are filled, this represents the filename "ABCDEFGH.JKL".
if not all are filled:
A B C D E F \0 \0 D O C
this represents "ABCDEF.DOC"
H E L L O \0 \0 \0 C \0 \0
this represents "HELLO.C"
One way to fill such a record is with strncpy:
char buf[11] = {0};
strncpy(buf, "HELLO", 8);
strncpy(buf + 8, "C", 3);
This way you can use the whole 8+3 space for the filename without
wasting space storing the dot or null terminators.
On modern systems which support very long filenames, it is
space-inefficient to use a fixed record width, which would
waste much space storing zeroes for shorter filenames, so new
variable length schemes have been introduced. However, fixed
width records still exist and are quite useful in other areas.