char *strcat(), *strcpy(), *fgets();
Doug Gwyn
gwyn at brl-smoke.ARPA
Sun Jun 26 12:16:39 AEST 1988
In article <11580010 at hpisod2.HP.COM> decot at hpisod2.HP.COM (Dave Decot) writes:
>> ... Here is a real example from source code
>> I happened to have open in another layer on my terminal:
>> (void)strcat(strcat(strcat(strcat(strcat(strcpy(fn, [...]
>This is much more efficiently (and readably!) rendered as:
> (void) sprintf(fn, "%s%s/%s/%s", TargetDir, target, approx, CCMAP);
What you say is true (indeed, the reason the code was open in a layer was
because I was straightening this out), but sometimes sprintf() is inadvisable
since it causes the general-purpose formatting package to be linked in from
the C library; in the unusal event that the application is not using stdio,
this adds substantially to the size of its executable image.
>... there's nothing to prevent adding more useful functions:
> [strecpy, strecat, strlcpy, strlcat]
Those are indeed useful, but probably the names should not start with "str",
to avoid conflicts with possible revisions of the C standard.
More information about the Comp.std.c
mailing list