Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.std.c Subject: Re: strncat is insufficient Message-ID: <1925@tkou02.enet.dec.com> Date: 16 Aug 90 00:31:39 GMT References: <2201@cirrusl.UUCP> <12570054@hpclscu.HP.COM> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 37 In article <12570054@hpclscu.HP.COM> shankar@hpclscu.HP.COM (Shankar Unni) writes: >Rahul: >> Most of the time I want to avoid string overflow by doing this: >> append str2 to str1, but cause at most n characters to be in str1. [me too -- Diamond] >Well, you could write a cheapo function that goes: > strlimcat (char *s1, char *s2, int n) { strncat (s1, s2, (n - strlen(s1))); } >which is exactly what strlimcat would have to do anyway.. Well, it's cheap in terms of development time, but not usually in execution time. You MIGHT have a super-optimizing compiler that has learned a trick (newly authorized by ANSI) of remembering that strlen and strcat are special, so it can remember that the length of s1 has been computed and does not have to be computed a second time. But you PROBABLY don't. >Doug G: >> There isn't much point in discussing it in this newsgroup. >> We're not soliciting suggestions for changes to the standard. >Ooohhh. Does that mean that C is frozen for eternity? The standard suggests that a few features might be deprecated in the future. >The "ultimate, greatest-ever language on earth"? This opinion seems to be widely held though (except for some of the adherents of C++). >I think this is an appropriate place for suggestions for extensions to the >language, too, in addition to questions about clarifications of items in >the current standard... I think so too. But these suggestions are not being solicited. Perhaps we need yet another newsgroup, which certain users would not want to read. comp.std.c.2001? -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com This is me speaking. If you want to hear the company speak, you need DECtalk.