strncpy()

Steve Summit stevesu at bronze.UUCP
Wed Aug 31 17:59:16 AEST 1983


(Tom Laidig pointed out that the sometimes peculiar behavior of
strncpy(), i.e. not always appending a '\0', is useful in strings
that need not be null terminated, like filenames in directories.)

By the way, that reminds me of a tidbit I learned while building
directories by hand (I was salvaging a trashed filesystem, and it
was PAINFUL): 

Those filenames that are shorter than DIRSIZE (14) characters
should be fully null padded.  The kernel must not use the strncmp()
I'm used to, because if there are characters other than '\0'
after the first '\0', it won't match.

					Steve Summit



More information about the Comp.lang.c mailing list