strncpy
Bill Poser
poser at csli.Stanford.EDU
Fri Dec 22 08:35:28 AEST 1989
I should clarify that: (a) I know perfectly well HOW strncpy works. My
question concerned the rationale for this design; (b) I know that it is
not hard to produce null-termination and indeed have my own version of
strncpy that does this. But the fact that it isn't hard to produce
null termination doesn't explain why the standard version was designed
the way it was. There is nothing terribly difficult about anything in the
string library.
So far I have heard of one good use for strncpy without null termination.
I have also been told that it is useful for copying into fixed length
char arrays which are not intended to be null-terminated when full.
I am aware of such string representations, but those aren't the standard
C string representation and so the question arises as to why the
standard string library should include a function that doesn't fit the
usual representation of strings.
More information about the Comp.lang.c
mailing list