strcpy
    Karl Heuer 
    karl at haddock.ima.isc.com
       
    Tue Jun 13 05:56:27 AEST 1989
    
    
  
In article <4400001 at tdpvax> scott at 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 at haddock.isc.com), The Walking Lint
    
    
More information about the Comp.lang.c
mailing list