Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!dayton!ems!meccts!nis!karau!stevew From: stevew@karau.UUCP Newsgroups: comp.arch,comp.lang.c Subject: Re: String Processing Instruction Message-ID: <467@karau.UUCP> Date: Sat, 11-Apr-87 12:13:08 EST Article-I.D.: karau.467 Posted: Sat Apr 11 12:13:08 1987 Date-Received: Sun, 12-Apr-87 17:40:58 EST References: <15292@amdcad.UUCP> <978@ames.UUCP> <15304@amdcad.UUCP> <486@danews.ATT.COM> Distribution: na Organization: Karau Assoc. Inc., Hopkins MN Lines: 24 Keywords: strlen strcmp strcpy Xref: utgpu comp.arch:839 comp.lang.c:1565 Summary: another cat() proposal In article <486@danews.ATT.COM>, lvc@danews.ATT.COM (Larry Cipriani) writes: > In article <15317@amdcad.UUCP>, rpw3@amdcad.UUCP (Rob Warnock) writes: > > I find myself doing: > > char *p = &buf[0]; > > int n; > > strcpy(p, "piece"); p += strlen(p); > > strcpy(p, "another piece"); p += strlen(p); > > etc... > It seems to me that the code would be far more readable and faster > if it were written as: > p = cat(p1, p2, ..., (char*)0); > where all the p's are pointers to characters. Cat will malloc > enough space to store a concatenation of all the pn's and a '\0'. Another possible solution would be: cat(p, n, p1, p2, ..., (char*)0); Where p == destination string, n == amount of space available, p1 == the first pointer, etc... You might have two versions one with n, one without. The debate is now what it should return: 1. pointer to the initial string. 2. the number of characters cat()'ed. 3. a pointer to the terminating null.