using "=" in a conditional (was Funny Mistake)
Sven Heinicke
sven at cs.widener.edu
Thu Mar 21 11:46:19 AEST 1991
In <11195 at dog.ee.lbl.gov>, torek at elf.ee.lbl.gov writes:
>In article <1991Mar20.031419.3677 at isis.cs.du.edu>
>cla at isis.UUCP (Chuck Anderson) writes:
>>You can do a nice string copy with this construct as well:
>> while (*dest++ = *source++);
When I read something like this I automaticely think not equal to zero.
>
>Of course, you can also write it as:
>
> while ((*dest++ = *source++) != 0) /* or != '\0' */
> /* void */;
>
And when I am typing c code, rather often my thincking goes much faster then
my typing, especialy with the the five kinds of key boards I normally use (IBM
PC, VT101, VT330, sunwork station and macintosh) and all of those symbols slow
me down. If I can pal to go through my program ofterwords I sometime put
in the != 0 but only in cases that get rather complicated arguments in c.
--
sven at cs.widener.edu Widener CS system manager
Sven Mike Heinicke and Student
(pssmheinicke at cyber.widener.edu (if you must))
More information about the Comp.lang.c
mailing list