Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!ucsd!ucbvax!agate!violet.berkeley.edu!lindahl From: lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) Newsgroups: comp.sys.mac.programmer Subject: Re: Disinfectant 2.0 Sample Code Message-ID: <1990Jul16.172225.28386@agate.berkeley.edu> Date: 16 Jul 90 17:22:25 GMT References: <9510@accuvax.nwu.edu> <40562@think.Think.COM> <25571@cs.yale.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) Organization: University of California, Berkeley Lines: 30 In article <25571@cs.yale.edu> tarr-michael@CS.YALE.EDU (michael tarr) writes: > >Think C 4.01 also has a bug in strncpy: > >char s1[10]; >char s2[20] = "A long string"; > >strncpy(s1, s2, 8); > >s1 will not have a '\0' appended to the end. So far as I can tell this >is not per the standard definition. ... >Mike Tarr >tarr@cs.yale.edu That's exactly the behavior I've always seen. According to the UPM: " string(3) The strcpy subroutine copies string s2 to s1, stopping after the null character has been copied. The strncpy subroutine copies exactly n characters, truncating s2 or adding null characters to s1 if necessary. The result will not be null-terminated if the length of s2 is n or more. Each function returns s1." Ken Lindahl lindahl@violet.berkeley.edu Advanced Technology Planning, Information Systems and Technology University of California at Berkeley