On 7 Oct 2006 06:38:50 -0700, "lovecreatesbea...@gmail.com"
<lo***************@gmail.comwrote:
>c-faq, 4.3:
The postfix ++ and -- operators essentially have higher precedence
than the prefix unary operators.
Notice the word essentially. In this context, it means what follows
is not precisely correct but has the same effect as if it were.
>
BSD Manual, OPERATOR(7):
Operator Associativity
-------- -------------
! ~ ++ -- - (type) * & sizeof right to left
Consider the following code snippet inside a function:
int i[2] = {3,4};
int *p = i;
int j = --*p++;
Since --, *, and ++ have the same "official" precedence,
associativity acts as a tie breaker. Thus, the right had side is
evaluated as --(*(p++)). This is the same result you would get IF
postfix had higher precedence than prefix.
p++ evaluates to the current value of p and sometime before this
statement is complete will increment p.
*p++ evaluates to 3, the value of the int p initially pointed to.
--*p++ evaluates to one less than this value and sometime before
the statement is complete will decrement the value in its original
location.
When all is said and done, j is assigned the value 2, i[0] is
decremented to 2, and p points to i[1] which is unchanged..
>
Is there a complete table on operators, their precedence and
associativity in the standard document?
If you have access to K&R, Table 2-1 on page 53 may be what you are
looking for.
Remove del for email