雖然到處都用括號括起來順序就一定不會錯,但是這樣寫code實在不方便閱讀
把優先序放在這邊方便參考
http://www.csee.umbc.edu/courses/104/fall06/burt/precedenceTable.html
Level | Symbol | Description | Associativity |
---|---|---|---|
1 | ++ -- ( ) [ ] -> . | Prefix increment Prefix decrement Function call and subexpression Array subscript Structure pointer Structure member | left to right |
2 | ! ~ - + (type) * & sizeof | Logical negation 1's complement Unary negation Unary plus Type cast Pointer dereference Address of Size of | right to left |
3 | * / % | Multiplication Division Modulus (integer remainder) | left to right |
4 | + - | Addition Subtraction | left to right |
5 | << >> | Bitwise left shift Bitwise right shift | left to right |
6 | < <= > >= | Less than Less than or equal to Greater than Greater than or equal to | left to right |
7 | == != | Equal test Not equal test | left to right |
8 | & | Bitwise AND | left to right |
9 | ^ | Bitwise exclusive OR (XOR) | left to right |
10 | | | Bitwise inclusive OR | left to right |
11 | && | Logical AND | left to right |
12 | || | Logical inclusive OR | left to right |
13 | ?: | Conditional test | right to left |
14 | = += -= *= /= %= <<= >>= &= ^= | | Assignment Compound add Compound subtract Compound multiply Compound divide Compound modulus Compound bitwise left shift Compound bitwise right shift Compound bise AND Compound bitwise exclusive OR Compound bitwise inclusive OR | right to left |
15 | , ++ -- | Sequence point (list separator) Postfix increment Postfix decrement | left to right |
沒有留言:
張貼留言