Article View: comp.std.c
Article #5097Re: char *strcat(), *strcpy(), *fgets();
From: Karl Heuer
Date: Thu, 30 Jun 1988 03:58
Date: Thu, 30 Jun 1988 03:58
16 lines
1380 bytes
1380 bytes
In article <568@tuck.nott-cs.UUCP> anw@maths.nott.ac.uk (Dr A. N. Walker) writes: >In article <2029@pt.cs.cmu.edu> jgk@speech2.cs.cmu.edu (Joe Keane) writes: >>To be useful, strcpy and strcat should return the end of the new string. > >If it has to be one or t'other, don't forget that the way C works it is >easier to find the end of a string given its beginning than to find its >beginning given its end. If strcpy() and strcat() return the beginning of the string, the cost of finding the end is O(N): you make another pass through the string. If they return the end of the string, the cost of finding the beginning is O(1): you already had the value, since you passed it as the first argument. At worst, you have to declare a temporary variable to hold it. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint Followups to comp.lang.c.
Technical Details
Message-ID:
<4855@haddock.ISC.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!spdcc!ima!haddock!karlReferences:
<haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl> <2029@pt.cs.cmu.edu> <568@tuck.nott-cs.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!spdcc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.std.c,comp.lang.c Subject: Re: char *strcat(), *strcpy(), *fgets(); Message-ID: <4855@haddock.ISC.COM> Date: 30 Jun 88 03:58:21 GMT References: <haddock.4604> <1719@ogcvax.ogc.edu> <1309@ark.cs.vu.nl> <2029@pt.cs.cmu.edu> <568@tuck.nott-cs.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Followup-To: comp.lang.c Organization: Interactive Systems, Boston Lines: 16