🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5124

Re: char *strcat(), *strcpy(), *fgets();

#5124
From: Joe Keane
Date: Thu, 23 Jun 1988 19:02
18 lines
1078 bytes
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
Technical Details
Message-ID: <2029@pt.cs.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!bloom-beacon!mit-eddie!bbn!rochester!pt.cs.cmu.edu!speech2.cs.cmu.edu!jgk
References: <haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl>
Sender: netnews@pt.cs.cmu.edu
Organization: Carnegie Mellon Computer Science
Lines: 18