it's not that C
prefers the "constant == variable" style of comparison, it's that that style makes it harder to commit destructive typos there. in C, namely, you can have an assignment inside a comparison statement; you can say things like,
which sets i to 1 and evaluates to true. (i think 1 is true in C; it's been a long while, it might be false.) this can actually be
useful, say if you want to set one variable to the value of another and then execute the body of the "if" statement only if that value is 1; that's kindof rare, but does happen. other languages force you to spell out what you're doing when you're doing that - this is intentional.
so, in C,
you should always take care to use "==" in comparisons to avoid possibly difficult-to-diagnose bugs. or, alternatively, take care to put the constant part of any comparison that involves a constant
first, since even in C, assigning to a constant is a compile-time error. considering possible typos, better to use both precautions.
(you've got to give C this much: at least it isn't FORTRAN.
in some early dialects of FORTRAN, you
could assign new values to constant literals... which were
global, no less! )
[ February 02, 2005: Message edited by: M Beck ]