Date: Thu, 25 Sep 1997 11:35:25 +0200 (IST) From: Eli Zaretskii To: "Art S. Kagel" cc: "Peter J. Farley III" , djgpp AT delorie DOT com Subject: Re: Problem with strncpy (DJGPP in msdos window in win95) In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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 ;-).