Actually, most modern compilers warn you if you do... while (*dest++ = *source++); ...with a message like "Possibly incorrect assignment", so I usually include the explicit comparison. I'm a big believer in readability, I hate going back to some of my own old code and not being able to figure out what I did, or why. Martin R. Green elimar@bigfoot.com On Fri, 10 Oct 1997 09:33:26 +1000, Clyde Smith-Stubbs wrote: >On Thu, Oct 09, 1997 at 03:48:51PM -0800, Andrew Warren wrote: >> Martin R. Green wrote: >> > > >> > > while (*dest++ = *source++); >> > >> > Copy the thing pointed to by the source pointer to the location >> > pointed to by the dest pointer, and increment the source and dest >> > pointers AFTER the thing has been copied, ready for the next thing. >> >> After every copy from source to destination, the "while" examines >> the value that was copied. If the value isn't equal to 0, the > >Just to expand further, this is really equivalent to > > while((*dest++ = *source++) != 0) > continue; > >And it's actually not a bad idea to write it like that. It should generate >exactly the same code as the original (if it doesn't, get a new compiler) >and it makes it clear what you're doing. In Java, using the explicit != >test is mandatory - Java does not allow arbitrary expressions to be used as >boolean values, to avoid errors like: > > if(fred = 1) > >which is legal C, but almost certainly was meant to be > > if(fred == 1) > >Then there's the hoary old trap that I still fall into occasionally: > > if(fred & 0x60 == 0x20) > >which should have been > > if((fred & 0x60) == 0x20) > >becuz & has a lower precedence than ==.