Hi, This is not a boolean comparison. It is an assignment. If the content of (*s) is not zero then the while condition is true. Moshe.
--- In [email protected], andrew clarke <[EMAIL PROTECTED]> wrote: > > On Mon, Aug 14, 2006 at 12:53:33PM -0400, Kerry Thompson wrote: > > > void strcpy (char *s, char *t) > > { > > while (*s++ = *t++); > > } > > > > This copies a character from t to s, THEN increments s and t, THEN does the > > boolean comparison. It's one of the most elegant pieces of C code I know. > > Are you sure the boolean comparison isn't done first, before the copy? > Someone new to C might wonder about that. > > The above is also one of the more difficult for programmers new to C > (and even old hacks like me!) to understand at first glance. If I saw > this sort of thing in modern "production" code I wouldn't be very happy. > There is no harm in expanding it out to aid readability and debugging. > Any modern compiler should optimise both versions to the same object > code. > To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/c-prog/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
