On Tue, Feb 06, 2001 at 06:17:46PM -0600, Ross J. Reedstrom wrote:
>
> Seems it's a non-portable behavior:
>
> The strncpy() function is similar, except that not more
> than n bytes of src are copied. Thus, if there is no null
> byte among the first n bytes of src, the result wil not be
> null-terminated.
>
> In the case where the length of src is less than that of
> n, the remainder of dest will be padded with nulls.
>
> I've already forgotten what platform the original bug report came from.
Just checked, D'Arcy never told us. But it doesn't matter, the manpage
lies. I just tested it with a tiny little program that copies two
different constant strings into a buffer. Nothing get's padded with nulls,
as Tom knew. Once again, experience trumps book knowledge. (Checking
a couple random examples from my own code, I seem to have lucked out:
I've a habit of zeroing my buffers myself)
Ross