[comp.std.c] H&S III strcat

vinoski@apollo.HP.COM (Stephen Vinoski) (03/19/91)

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@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       |

morgan@ogicse.ogi.edu (Clark O. Morgan) (03/20/91)

In article <5075771f.20b6d@apollo.HP.COM> vinoski@apollo.HP.COM (Stephen Vinoski) writes:

 ...[omitted strcat example]

>(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?)

Oh no, say it isn't so!  H&S I was my definitive K&R C reference
manual.  I recently bought H&S III, but have not had time to read
it, yet.

Anyone else out there want to post a review?

Thanks in advance.
-- 
Clark O. Morgan     morgan@cse.ogi.edu     ...!uunet!ogicse!morgan

diamond@jit345.swstokyo.dec.com (Norman Diamond) (03/20/91)

In article <5075771f.20b6d@apollo.HP.COM> vinoski@apollo.HP.COM (Stephen Vinoski) writes:

>... 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?

No.

>Does anybody actually proofread technical books before publishing them anymore?

Did they ever?
Part of the folklore is that examples should be tested before publishing.
It is a rare author who actually does so.  I'm glad if you can get a refund.
--
Norman Diamond       diamond@tkov50.enet.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.

gwyn@smoke.brl.mil (Doug Gwyn) (03/21/91)

In article <5075771f.20b6d@apollo.HP.COM> vinoski@apollo.HP.COM (Stephen Vinoski) writes:
>Since the return value does not point to the beginning of the original s1, is
>this implementation standard-conforming?

Obviously you know the answer to that..

>Does anybody actually proofread technical books before publishing them ...

"Proofreading" is not the right term for what you are concerned about.
"Reviewing" would be more accurate.  Yes, technical books are generally
reviewed; however, the reviewers can make mistakes too, and even if they
don't, due to the iterative editing of the manuscript mistakes can occur.

egr@contact.uucp (Gordan Palameta) (03/22/91)

In <18851@ogicse.ogi.edu> morgan@ogicse.ogi.edu (Clark O. Morgan) writes:

>Oh no, say it isn't so!  ...

>Anyone else out there want to post a review?


Well, H&S II contained at least 3 blatant errors in the ASCII table,
and the truth tables for && and || were identical.  Looks like they got
the big things right but goofed badly on absolutely trivial stuff.

This fixed in III?

pas@unhd.unh.edu (Paul A. Sand) (03/24/91)

In article <1991Mar22.030139.15169@contact.uucp> egr@contact.uucp (Gordan Palameta) writes:
>Well, H&S II contained at least 3 blatant errors in the ASCII table,
>and the truth tables for && and || were identical.  Looks like they got
>the big things right but goofed badly on absolutely trivial stuff.

>This fixed in III?

Well... on the bottom of page 197 of H&SIII, there's a table that says,
in part:

	a	b ... a || b
	1	0 ...    0

-- 
-- Paul A. Sand                | Disclaimer: The opinions expressed
-- University of New Hampshire | herein are my own. Duh.
-- uunet!unhd!pas              |      (Jim Showalter)
-- pas@unhd.unh.edu            |