(a) ptr != 0 && *ptr++
The expression means if ptr
is not null pointer, then point to whatever next in memory and return a copy of the value of the original int
variable. Since we don't know what next in memory is, it will be an error if we dereference ptr
after the expression. The expression may be:
ptr != 0 && (*ptr)++
(b) ival++ && ival
The expression first increases the value of ival
and return a copy of the original value, then if the original value is nonzero, the right hand operand ival
(the incremented one) is evaluated, if it is also nonzero, the expression is true
, else it is `false.
(c) vec[ival++] <= vec[ival]
The order of evaluation of <=
operator's operands is undefined. The expression should be:
++ival, vec[ival] <= vec[ival + 1]