*a = *b In C, the above expression is always interpreted as the assignment of the value at the address contained in b to the value at an address in a. But, according to the precedence of operators and associativity rule, * has higher priority than the assignment operator '=', and is associative from right to left. If we interpret the given expression keeping in mind these rules, it should be interpreted as:



10=20(Supposing *a=10 & *b=20)

So, this must result in an error if taken as per the rules of precedence and also as per the rule that there can't be an expression on the left-hand side of an assignment operator. Then why does this work?


1 Answer 1


I'm not sure if this is in topic here.

Anyway, (*a) in (*a)=(*b) denotes a lvalue referring to the object in a. On the right side of the assignment, (*b) also denotes an lvalue, but this lvalue undergoes lvalue conversion and is converted to the actual value stored in the object pointed by $b$ (i.e., to 20).

In the end, the value 20 is assigned to the object pointed by a.

See, for example, this discussion about lvalues and rvalues.

  • $\begingroup$ Got it...thank you so much. $\endgroup$ Commented Jul 2, 2021 at 21:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.