next up previous contents index
Next: Concatenation functions Up: Copying functions Previous: The strcpy function

The strncpy function

strncpy

strncpy was initially introduced into the C library to deal with fixed-length name fields in structures such as directory entries. Such fields are not used in the same way as strings: the trailing null is unnecessary for a maximum-length field, and setting trailing bytes for shorter names to null assures efficient field-wise comparisons. strncpy is not by origin a ``bounded strcpy,'' and the Committee has preferred to recognize existing practice rather than alter the function to better suit it to such use.

4 11 3


Pete Jinks
Fri Jan 19 12:31:56 GMT 1996