home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c:12652 comp.std.c:2490
- Path: sparky!uunet!olivea!mintaka.lcs.mit.edu!spdcc!iecc!johnl
- From: johnl@iecc.cambridge.ma.us (John R. Levine)
- Newsgroups: comp.lang.c,comp.std.c
- Subject: Re: strcpy implementation question
- Message-ID: <1992Aug22.132132.13813@iecc.cambridge.ma.us>
- Date: 22 Aug 92 13:21:32 GMT
- References: <PINKAS.92Aug21114508@caraway.intel.com>
- Distribution: comp
- Organization: I.E.C.C.
- Lines: 20
-
- >If the sizes of the src and dst are known at compile time (e.g. they are
- >both declared in the current file as static or auto arrays), ...
- >In order to avoid checking every byte, they
- >plan to copy past the terminator ('\0'), and copy a number of bytes equal
- >to the smaller of the src or dst.
-
- 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.
-
- --
- John R. Levine, IECC, POB 349, Cambridge MA 02238, +1 617 492 3869
- johnl@iecc.cambridge.ma.us, {ima|spdcc|world}!iecc!johnl
- Re-elect Vice President Potatoe-Head !
-