msb@sq.UUCP (03/30/87)
> > sprintf(p, "format%d%s", args...); p+= strlen(p); > Wouldn't it have been nice if strcpy(), strcat(), sprintf(), etc. > had been designed to return a pointer to the END of the string, > (or a count of the number of characters in the string)? In some C implementations, sprintf() DOES return a count of the number of characters that it wrote. I find this behavior in a System V manual, for instance, and on VMS. Since both behaviors existed, the ANSI people were able to choose the more useful one, and the October 1986 draft mandates that sprintf() returns a count. Unfortunately this does not apply to the other string functions. Also unfortunately, the new book "Portable C and UNIX System Programming" by "J. E. Lapin" misses this one. (That's why I had to check manuals...) Meanwhile, until ANSI C is universal, we should all be careful NOT to assume that we know what type sprintf() returns... Mark Brader "Perhaps their software was written by a Byzan-tine-ager" utzoo!sq!msb -- Peter Neumann