char *strcat(), *strcpy(), *fgets();
Karl Heuer
karl at haddock.ISC.COM
Thu Jun 30 13:58:21 AEST 1988
In article <568 at tuck.nott-cs.UUCP> anw at maths.nott.ac.uk (Dr A. N. Walker) writes:
>In article <2029 at pt.cs.cmu.edu> jgk at 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 at haddock.isc.com), The Walking Lint
Followups to comp.lang.c.
More information about the Comp.lang.c
mailing list