Thread View: news.software.readers
1 messages
1 total messages
Started by Jeff-Relf.Me
Wed, 31 May 2017 19:30
The EvaluationOrder/Precedence of C/C++ Operators.
Author: Jeff-Relf.Me
Date: Wed, 31 May 2017 19:30
Date: Wed, 31 May 2017 19:30
43 lines
2972 bytes
2972 bytes
<PRE Style='Font-Family: OCR A, monospace !important;'>
The Evaluation Order of these expressions are UnDefined/SemiRandom:
i = ++i + i++ ; i = i++ + 1 ; Array[ i ] = i++ ;
Func( ++i, ++i ); Func( i = -1, i = -1 ); Func( i, i++ );
http://en.cppreference.com/w/c/language/eval_order
The middle part of a Conditional Expression ( between ? and : )
is parsed as if parenthesized; for example:
int rv, zz ;
zz = 1, rv = zz ? zz = 1, 2 : zz = 3, 6 ;
printf( L"%d and %d", rv, zz ); // Prints: " 2 and 1 ".
zz = 0, rv = zz ? zz = 1, 2 : zz = 3, 6 ;
printf( L"%d and %d", rv, zz ); // Prints: " 3 and 3 ".
http://en.cppreference.com/w/c/language/operator_precedence
Precedence of C Operators:
Associativity
( Left to right ) Category Operator
----------------- --------------- ----------------------------------------------
Postfix Unary Func() [] -> . ++ --
Right to left Prefix Unary + - ! ~ ++ -- (type) * & sizeof
Multiplicative * / %
Additive + -
Shift << >>
Relational < <= > >=
Equality == !=
Bitwise AND &
Bitwise XOR ^
Bitwise OR |
Logical AND &&
Logical OR ||
N/A Conditional Bool ? True : False
Right to left Assignment = += -= *= /= %= >>= <<= &= ^= |=
Comma ,
http://en.cppreference.com/w/c/language/operator_precedence
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads