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

Skip Tavakkolian fst at mcgp1.UUCP
Fri Jul 1 12:31:47 AEST 1988


In article <4773 at haddock.ISC.COM>, karl at haddock.ISC.COM (Karl Heuer) writes:
> In article <11580010 at hpisod2.HP.COM> decot at hpisod2.HP.COM (Dave Decot) writes:
> >While it's clear that we can't change the return value of strcat() because
> >of applications (such as the one above) that use it, there's nothing to
> >prevent adding more useful functions:
> Since this is comp.std.c, I'll redeclare your list in ANSI.
> >    char *strecpy(char *, char *)
> >    char *strecat(char *, char *)
> >    size_t strlcpy(char *, char *)
> >    size_t strlcat(char *, char *)
> Actually, given a useful set of end-string functions (including the simplest
> one, "char *strend(char *)"), I see no need for any of the "cat" functions.
> Even the standard strcat(x,y) is just strcpy(strend(x),y), and if the
> application was designed properly it probably already has the value of
> strend(x) in hand.
> As Doug has noted, "str*" is reserved to the implementation.  Thus, the vendor
> is free to add any of these to <string.h> as an extension (and would still
> have a conforming implementation).  I suppose many implementations will put
> strdup() there.
> Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint


Whitesmiths Ltd. had (still has but are now called WSL extensions to ANSI C),
several library routines dealing with multiple copy operations. For example:

	/* I do not recall the return value, but I think it is */
	char *cpystr(destination, _1st_source [, _2nd_source, ...], NULL)
		char *destination, *_1st_source, *_2nd_source, ...;

	/* last arg passed has to be `NULL' */

so that you can say:

	char buf[BUFSIZ];
	cpystr(&buf[0], "This ", "is ", "a test", NULL);

I think this will do what, the original code that was posted, was trying to.
(Yes/No)?

Sincerely
-- 
Fariborz ``Skip'' Tavakkolian

UUCP	...!uw-beaver!tikal!mcgp1!fst



More information about the Comp.std.c mailing list