4 ms·
strncpy() suffers from its naming. It never was a string function in reality. It is a function to write and clear a fixed size buffer. It was invented to write
by schlupa 6y ago
strncpy() suffers from its naming. It never was a string function in reality. It is a function to write and clear a fixed size buffer. It was invented to write filenames in the 14 character buffer of a directory entry in early Unix. It should have been name mem-something and people would have never come to the idea to use it for general string routines.
- JoeAltmaier 6y agoIf it respects null terminator, then it is a string function.
- slrz 6y agoIt basically expects a string as the source and a fixed-size, not necessarily zero-terminated, buffer as the destination.