home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:12762 comp.std.c:2510
- Newsgroups: comp.lang.c,comp.std.c
- Path: sparky!uunet!uunet.ca!wildcan!sq!msb
- From: msb@sq.sq.com (Mark Brader)
- Subject: Re: strcpy implementation question
- Message-ID: <1992Aug25.170433.10110@sq.sq.com>
- Organization: SoftQuad Inc., Toronto, Canada
- References: <1992Aug22.132132.13813@iecc.cambridge.ma.us> <1992Aug23.003930.9918@saaf.se> <1992Aug25.063134.18645@netfs.dnd.ca>
- Date: Tue, 25 Aug 92 17:04:33 GMT
- Lines: 35
-
- In articles whose Distribution lines are invalid (don't do that!),
- John R. Levine (johnl@iecc.cambridge.ma.us) writes:
-
- > > In my copy of the C standard, section 4.1.1 says "a string is a contiguous
- > > sequence of characters terminated by and including the first null
- > > character." Section 4.11.2.3 says "The strcpy function copies the string
- > > pointed to by s2 (including the terminating null character) into the array
- > > pointed to by s1."
- > >
- > > But it doesn't say "(including the terminating null character and any other
- > > garbage convenient for the compiler implementer)". You have to stop at the
- > > null byte.
-
- And Bob Balkwill (balkwill@ncs.dnd.ca) replies:
-
- > Sorry - but one cannot assume more than the C std declares. Maybe old
- > ill-advised code will break, but what happens after the null byte is up for
- > grabs. ...
-
- However, one can assume *as much* as the standard declares.
-
- As I said in email to the original poster, the standard also does not say
- that strcpy() doesn't write "Mark is an idiot\n" to stdout. It doesn't have
- to! [Er, I mean that the standard doesn't have to say that, not that
- strcpy() doesn't have to write that. :-)] The descriptions in part 4 of
- the standard tell *everything* that the functions are supposed to do.
-
- The string is terminated by the null character, and copying any more is
- an error. John is right. In my educated opinion.
- --
- Mark Brader "A clarification is not to make oneself clear.
- SoftQuad Inc., Toronto It is to PUT oneself IN the clear."
- utzoo!sq!msb, msb@sq.com -- Lynn & Jay, "Yes, Prime Minister"
-
- This article is in the public domain.
-