strncpy

Bill Poser poser at csli.Stanford.EDU
Sat Jan 6 08:47:58 AEST 1990


In article <000003Q at cdis-1.UUCP> tanner at cdis-1.UUCP (Dr. T. Andrews) writes:
>Your consideration of strcpy()/strncpy() is more than a little
>reminiscent of a man who has in hand a claw hammer and a ball peen
>hammer, and who wishes to know why he can't pull nails with the
>latter.

Not really. It's more like the question of why the carpentry shop
has a ball peen hammer (used for metal working) and doesn't have
a claw hammer. strncpy is a function evidently designed for use with
fixed-length character buffers, not the null-terminated strings that
are semi-standard in C. That makes one wonder why strncpy is included
with functions that are intended for use with null-terminated strings,
and why there is no "safe" copying function for the latter.



More information about the Comp.lang.c mailing list