Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!mcnc!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: strcpy Message-ID: <13674@haddock.ima.isc.com> Date: 12 Jun 89 19:56:27 GMT References: <4400001@tdpvax> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 15 In article <4400001@tdpvax> scott@tdpvax.UUCP writes: >The second question deals with strcpy(). Is it like memcpy in that if the >arguments memory overlap the behavior is undefined or is it different. Is >pre-ANSI and ANSI different on this. In both pre-ANSI and ANSI, strcpy() has the same disclaimer as memcpy(). If you want to copy overlapping strings, you should probably use memmove(dest, src, strlen(src)); since memmove() does have predictable behavior on overlap. (In all known implementations, strcpy() happens to do the right thing for ONE direction of copy, but this has never been guaranteed, and I wouldn't try to rely on it.) Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint