On Tue, 3 Dec 2002, Michal Janusz Miroslaw wrote: [...]
Since we are talking about catenating strings only (no %d and family), then I would suggest combining speed of cpycat (in glibc there's stpcpy) and ease of use of sprintf and use something like that:
[...]
Then we could write:
strpcpymore(buffer, "path", "/", "file", ".", "ext", NULL);
Yep, that looks good. I guess it would return a pointer to the terminating '\0' too :-) However I have to note that it is a bit less flexible than the basic cpycat as you cannot do things like:
cpycat(buf,foo); if (condition1) cpycat(buffer,bar); if (condition2) cpycat(buffer,stuff); cpycat(buffer,more);
But yes, any of these would have been better than the braindead strcpy and strcat implementations we have in C libraries.