Sunner Sun <su********@163.com> scribbled the following:
Hi!
In some compiler, the relational expression's value is 1 for true or 0 for
false. Is this a stardard? Or is there any other compilers which use 0 and
other Non-zero value?
All comparison operators ==, !=, <, >, <= and >= are guaranteed to
return 1 for true and 0 for false. However, any non-zero value can be
used for true in conditional statements.
For example:
int a = 2==2; /* a is guaranteed to be 1 */
if (2) {
printf("This is guaranteed to be executed\n");
}
--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\--
http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Bad things only happen to scoundrels."
- Moominmamma