Article View: comp.std.c
Article #1594Re: strncat is insufficient
From: Shankar Unni
Date: Tue, 14 Aug 1990 23:44
Date: Tue, 14 Aug 1990 23:44
35 lines
1659 bytes
1659 bytes
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.
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..
Doug G:
> >I think the standard C library badly needs another function called,
> >say, strlimcat(), which limits the length of the destination string to
> >some value.
>
> Feel free to implement one of these for your own applications.
> 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 "ultimate,
greatest-ever language on earth"? I hardly think so.
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...
$0.02,
-----
Shankar Unni E-Mail:
Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com
Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar
Technical Details
Message-ID:
<12570054@hpclscu.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc01!hpcuhb!hpcllla!hpclisp!hpclscu!shankarReferences:
<2201@cirrusl.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!sdd.hp.com!hplabs!hpcc01!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.std.c Subject: Re: strncat is insufficient Message-ID: <12570054@hpclscu.HP.COM> Date: 14 Aug 90 23:44:38 GMT References: <2201@cirrusl.UUCP> Organization: Hewlett-Packard Calif. Language Lab Lines: 35