[comp.lang.c] I am an Idiot

mike@thor.acc.stolaf.edu (Mike Haertel) (08/25/89)

In some article or another @thor.stolaf.edu, I asserted that the
following:

char *
strcpy(char *s, const char *t)     /* NOT REALLY!!! */
{
	char *r = s, c;

	while (c = *t++)
		*s++ = c;
	return r;
}

was an implementation of strcpy that wouldn't compute &c + 1
given arguments strcpy(&c, "").  True.  However, it also would
not copy the final NUL byte of the source string.  THus,
the subject: line on this message.  Insert "*s = c;" before
the return statement.
-- 
Mike Haertel <mike@stolaf.edu>
``There's nothing remarkable about it.  All one has to do is hit the right
  keys at the right time and the instrument plays itself.'' -- J. S. Bach