strcpy

j.r.lupien jrl at anuck.UUCP
Thu Mar 24 02:29:28 AEST 1988


>From article <793 at cresswell.quintus.UUCP>, by ok at quintus.UUCP (Richard A. O'Keefe):
> The UNIX manuals say of strcpy(s1, s2) that it
> 	"copies s2 to s1, stopping after the null character has been copied."
> While they doesn't strictly speaking say anything about the order in which
> the other characters are copied, they _do_ say that the NUL character must
> be copied last, so 
Stopping after something occurs, as with "after the NULL has been copied"
does NOT equate, as you go on to assume, to "nothing will be done after
the NULL is copied. The function will return immediately." The definition
says "after". "After", as I recall, means "not before", which in no way
precludes doing the required act first, and taking care of other
requirements next. 
  As an aside, I would be loathe to assume that the string was copied
front to rear even if the function WAS so specified. Documentation
has been known in the past to lag or lead the actual code, or to
simply ignore it. 
  The moral of this is, don't depend on bizarre side effects unless
there is no other efficient way to get the job done, and even then
be quite sure that things work the way you expect (test it). Be
prepared to adopt some less efficient method, because you WILL get
bitten.

John R. Lupien
twitch!mvuxa!anuxh!jrl


Watch out for that pirrhana!



More information about the Comp.lang.c mailing list