- 论坛徽章:
- 0
|
3.6.4.1 The if-else statement
Constraints
The controlling expression of an if statement shall have scalar type.
Semantics
In both forms, the first substatement is executed if the expression
compares unequal to 0. In the else form, the second substatement is
executed if the expression compares equal to 0. If the first
substatement is reached via a label, the second substatement is not
executed.
An else is associated with the lexically immediately preceding else
-less if that is in the same block (but not in an enclosed block).
摘自 ANSI C X3.159-1989
由此可见,两种写法在逻辑上完全等价,因为都是在和 0 比较。
[ 本帖最后由 langue 于 2009-1-20 22:30 编辑 ] |
|