strncat is insufficient

Henry Spencer henry at zoo.toronto.edu
Sun Aug 26 12:38:59 AEST 1990


In article <620.26d6d0cd at iccgcc.decnet.ab.com> browns at iccgcc.decnet.ab.com (Stan Brown, Oak Road Systems) writes:
>Can Karl, or someone else who knows, explain why strncpy was standardized
>to copy n characters even at the expense of a zero byte...

Because that is the way strncpy() behaved in existing implementations,
and there was code that depended on it.

> or why no
>alternative that always terminates the string was provided...

Because there was no such alternative that had been implemented and used.

ANSI C standardized -- by and large -- an existing language.  This is a
feature, not a bug.
-- 
Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology
                       -Freeman Dyson  |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.std.c mailing list