home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / c / 12858 < prev    next >
Encoding:
Internet Message Format  |  1992-08-27  |  1.2 KB

  1. Xref: sparky comp.lang.c:12858 comp.std.c:2522
  2. Path: sparky!uunet!mcsun!uknet!warwick!coventry!ccx018
  3. From: ccx018@cch.coventry.ac.uk (Leslie Griffiths (Griff))
  4. Newsgroups: comp.lang.c,comp.std.c
  5. Subject: Re: strcpy implementation question
  6. Message-ID: <Btn96J.3J8@cck.coventry.ac.uk>
  7. Date: 27 Aug 92 13:23:06 GMT
  8. References: <1992Aug23.003930.9918@saaf.se> <1992Aug23.194919.22007@iecc.cambridge.ma.us> <23531@alice.att.com>
  9. Sender: news@cck.coventry.ac.uk (news user)
  10. Organization: Coventry University
  11. Lines: 28
  12. Nntp-Posting-Host: cc_sysh
  13.  
  14. In article <23531@alice.att.com> ark@alice.UUCP () writes:
  15. >In article <1992Aug23.194919.22007@iecc.cambridge.ma.us> johnl@iecc.cambridge.ma.us (John R. Levine) writes:
  16. >
  17. >>     static char buf[6];
  18. >
  19. >>     strcpy(buf+3, "cd");
  20. >>     strcpy(buf, "ab");
  21. >
  22. >> If buf doesn't end up containing "ab\0cd\0" I'd say that something was
  23. >> seriously wrong.
  24. >
  25. >If you make that "abcd\0", I'll agree with you.
  26.  
  27. I think Mr Levine is correct. The second strcpy copies a and b to locations
  28. buf[0] and buf[1], and then a null, so we have:
  29.  
  30.     buf[0] = a, buf[1] = b, buf[2] = \0
  31.  
  32. >                --Andrew Koenig
  33.  
  34.  
  35. Cheers
  36.  
  37.  
  38. -- 
  39. Griff                \\             ccx018@uk.ac.cov
  40. ^^^^^                        :-=           ^^^^^^^^^^^^^^^^
  41.                     //
  42.