Path: utzoo!utgpu!water!watmath!clyde!att!pacbell!ames!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.std.c Subject: Re: char *strcat(), *strcpy(), *fgets(); Message-ID: <8160@brl-smoke.ARPA> Date: 26 Jun 88 02:16:39 GMT References: <1309@ark.cs.vu.nl> <11580010@hpisod2.HP.COM> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB)) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 19 In article <11580010@hpisod2.HP.COM> decot@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.