Mail Archives: djgpp/1997/09/25/05:35:54
On Wed, 24 Sep 1997, Art S. Kagel wrote:
> Peter's
> recommended code is correct, very standard (I do it that way myself),
> and very efficient (the, perhaps unneccessary assignment is a lot
> cheaper than the test that could eliminate it).
Another simple solution to this problem is to initialize the buffer
with a single '\0' character, then use `strncat' instead of `strncpy'.
A frequently-overlooked feature of `strncat' is that it *always* puts
the terminating null character after the copied characters.
(Maybe I should make this the tip of the week ;-).
- Raw text -