value of TRUE???
Colin Plumb
w-colinp at microsoft.UUCP
Wed Mar 8 06:10:13 AEST 1989
Sigh, this went around a few short weeks ago...
When a C operator returns a truth value (these operators are
==, !=, <, > , <=, >=, !, &&, || and defined()), the result is
of type int and has the value 0 (for false) or 1 (for true).
When a C operator takes a truth value (!, &&, ||, ? :, if(),
if() else, while(), do while(), and for(;;), and #if), the
value must be comparable to 0 (i.e. int, float, pointer, etc.)
and if it is non-zero, it is considered to be true.
An if() statement does not return a value, so I don't quite understand
that part of the original question. if(i=3)... is equivalent to
i=3; if(i)... (assuming i isn't a macro). If i is 2 bits or wider,
this is equivalent to i=3; if(3)... which is equivalent to i=3; if(1)...
(or if(0.0001)... or if(&i)... or if(-1)...).
--
-Colin (uunet!microsoft!w-colinp)
"Don't listen to me. I never do." - The Doctor
More information about the Comp.lang.c
mailing list