Path: utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!bbn!rochester!pt.cs.cmu.edu!speech2.cs.cmu.edu!jgk From: jgk@speech2.cs.cmu.edu (Joe Keane) Newsgroups: comp.std.c Subject: Re: char *strcat(), *strcpy(), *fgets(); Message-ID: <2029@pt.cs.cmu.edu> Date: 23 Jun 88 19:02:52 GMT References:<1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl> Sender: netnews@pt.cs.cmu.edu Organization: Carnegie Mellon Computer Science Lines: 18 To be useful, strcpy and strcat should return the end of the new string. The old method is this: (void) strcpy (base, "foo"); (void) strcat (base, "bar"); (void) strcat (base, "baz"); This can be replaced by: end = strcpy (base, "foo"); end = strcpy (end, "bar"); (void) strcpy (end, "baz"); or more concisely: (void) strcpy (strcpy (strcpy (base, "foo"), "bar"), "baz"); If you're concatenating many strings, remember this is linear while the old method is quadratic. Unfortunately, there's no chance of getting this changed. I already have a function like this, i just don't call it strcpy. --Joe