Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!wuarchive!swbatl!texbell!texsun!newstop!sun!kuro From: kuro@vodka.Sun.Com (Teruhiko Kurosaka - Sun Intercon) Newsgroups: comp.lang.c Subject: Re: strncpy Message-ID: Date: 6 Jan 90 09:44:31 GMT References: <11527@csli.Stanford.EDU> <000003Q@cdis-1.UUCP> <11616@csli.Stanford.EDU> Sender: news@sun.Eng.Sun.COM Reply-To: kuro@Corp.Sun.Com Organization: Sun Microsystems Inc, Mt.View, CA, USA Lines: 15 In-reply-to: poser@csli.Stanford.EDU's message of 5 Jan 90 21:47:58 GMT In article <11616@csli.Stanford.EDU> poser@csli.Stanford.EDU (Bill Poser) writes: |are semi-standard in C. That makes one wonder why strncpy is included |with functions that are intended for use with null-terminated strings, |and why there is no "safe" copying function for the latter. I have no opinion about philosophical correctness of the current behavior of strncpy() but always do: strncpy(to, from, n); to[n]=0; This ensures the copied string is always null-terminated, if this is what you mean by "safe". -- ------- T. Kurosaka ("Kuro") --- Sun Microsystems, Intercontinental Operation Internet:kuro@Corp.Sun.Com Voice:+1(415)496-6121/336-5921 Fax:+1(415)858-0284 Mail: Mail Stop A6-18, 1870 Embarcadero Rd., Palo Alto, CA 94303, USA