Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!ima!haddock!karl From: karl@haddock.UUCP Newsgroups: comp.lang.c Subject: Re: String Processing Instruction Message-ID: <419@haddock.UUCP> Date: Mon, 30-Mar-87 19:31:41 EST Article-I.D.: haddock.419 Posted: Mon Mar 30 19:31:41 1987 Date-Received: Wed, 1-Apr-87 02:04:19 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> <15304@amdcad.UUCP> <232@winchester.mips.UUCP> <15317@amdcad.UUCP> Reply-To: karl@haddock.ISC.COM.UUCP (Karl Heuer) Distribution: na Organization: Interactive Systems, Boston Lines: 19 In article <15317@amdcad.UUCP> rpw3@amdcad.UUCP (Rob Warnock) writes: >[Sometimes instead of using strcat] I find myself doing: > char *p = &buf[0]; > strcpy(p, "piece"); p += strlen(p); > strcpy(p, "another piece"); p += strlen(p); > sprintf(p, "format%d%s", args...); p+= strlen(p); > strcpy(p, "still another piece"); p += strlen(p); > etc... Me too. I wish strcpy et al would return a pointer to the *end* of the copied string (fgets too, as someone else brought up). In fact, one could argue that the low-level routine should not even bother to write the final '\0'; then your example would become *_strcpy(_sprintf(_strcpy(_strcpy(p, "piece"), "another piece"), "format%d%s", args...), "still another piece") = '\0'; (Which can still be written using temporaries if the code gets too opaque!) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint