On Thu, 2010-12-02 at 13:15 -0800, Fred Cisin wrote:
A sparse commenting style that one might get away with
in many other
languages, can be a disaster in C. Consider
while (*t++=*s++);
That's easy. A string copy. The null-terminator is binary value 0, and
any value which is nonzero is considered to be 'true' in the context of
C Boolean statements.
Thus, we have a loop that copies from 's' to 't' until it hits a NULL,
then it bails out, having completely trashed both pointers. Hope you
kept a backup copy (or this piece of code was part of a 1-line strcpy
function, in which case "the stack saved ya!") !
--
Phil.
philpem at philpem.me.uk
http://www.philpem.me.uk/