H&S III strcat() wrong?

Stephen Vinoski vinoski at apollo.HP.COM
Wed Mar 20 00:57:00 AEST 1991


I just received my copy of the 3rd edition of "C: A Reference Manual" by
Harbison and Steele.  They state that the strcat() function can be implemented
as:

          char *
          strcat(char *s1, const char *s2)
          {
            s1 += strlen(s1);
            strcpy(s1, s2);
            return s1;
          }

Since the return value does not point to the beginning of the original s1, is
this implementation standard-conforming?

(BTW, in the ~50 pages I read of H&S III last night, I found lots of blatant
typographical errors, some of them in the function prototypes for standard
library functions.  I'm returning the book to Prentice-Hall and letting them
know that their quality needs heavy improvement.  Does anybody actually
proofread technical books before publishing them anymore?)


-steve
| Steve Vinoski  (508)256-0176 x5904       | Internet: vinoski at apollo.hp.com  |
| HP Apollo Division, Chelmsford, MA 01824 | UUCP: ...!apollo!vinoski         |
| "The price of knowledge is learning how little of it you yourself harbor."  |
|                                                    - Tom Christiansen       |



More information about the Comp.std.c mailing list