B
Ben Pfaff
Guillaume said:Is it? I'm not sure you understood what I meant by that.
If && and || don't have equal priority, which of them
has higher priority then? Good luck. ;-)
You're using an undefined term here. There's no reference to
"priority" in the C standard. I think you're thinking of
"precedence", which is at least referenced in sidelong ways in
the Standard.
The && operator has higher precedence than || does in C. You can
read the grammar given in the C standard to verify this:
logical-AND-expression:
inclusive-OR-expression
logical-AND-expression && inclusive-OR-expression
logical-OR-expression:
logical-AND-expression
logical-OR-expression || logical-AND-expression
Both logical operators guarantee left-to-right evaluation,
and that is it. This does not add up to different priority
in the algebraic sense, as in: 'A + B * C'. This is what
I meant. '*' has higher priority than '+'.
I don't think mathematicians call this priority either. It is
the "order of operations" or "precedence" of operators. Again,
&& has higher precedence than ||.
Is what I said clearer now?
No. You're not using the right terms.