andrew clarke wrote: > Are you sure the boolean comparison isn't done first, before the copy?
Yup. Strings in C are terminated with ASCII 0. When that 0 is copied, *s == 0, which is equivalent to false. The while loop terminates, and s and t are not incremented. Moshe is technically right. This is an assignment, not a boolean comparison. But a "while" loop acts on a true/false--or, more accurately, 0/!0--condition. So, pardon my shorthand, but it acts the same as a boolean comparison. > 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. I agree. Code should be written so you can read it--or your successor, 10 years later, can read it and easily understand it. It suited my purposes to illustrate the post-increment concept here, though. In fact, Kernighan and Ritchie go through a half-dozen iterations of the code in their book, gradually paring it down from a ~10-line function to the one-liner I quoted. If anybody has trouble following the code, I'd recommend you go to Kernighan and Ritchie's book, around page 105, and follow their logic. Cordially, Kerry Thompson 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/
