[Sussex] Re: C programming help - again!

Steve Dobson steve at dobson.org
Tue May 10 22:14:48 UTC 2005


Thomas

On Tue, May 10, 2005 at 07:02:32PM +0100, Thomas Adam wrote:
> On Tue, May 10, 2005 at 06:52:14PM +0100, Captain Redbeard wrote:
> > OK, got it on the error. I've fixed it with the strcpy() function at
> > it runs as expected. Now I've got the exciting job of re stripping
> 
> That would be """fixed""" as opposed to just 'Fixed' -- strncpy() is the
> function you should use -- it's much better than the much older
> stncpy(), doesn't allow for buffer-overflows on non-terminated strings
> as easily, and whatnot.

Unless he is malloc()ing the memory just before the str[n]cpy() in 
which case he may as well use strdup() to malloc() and str[n]cpy() in
one go.

Steve




More information about the Sussex mailing list