2 ms·
Yes. strncpy was intended for copying file names into a buffer that was only zero terminated when the name was shorter than the maximum length of a file name in
by Someone 6y ago
Yes. strncpy was intended for copying file names into a buffer that was only zero terminated when the name was shorter than the maximum length of a file name in Unix (14 bytes. See https://stackoverflow.com/a/1454071 https://stackoverflow.com/a/1454071, https://devblogs.microsoft.com/oldnewthing/20050107-00/?p=36773 https://devblogs.microsoft.com/oldnewthing/20050107-00/?p=36...)
You can also use it to overwrite part of an existing string, but I think that’s a side effect of the above.