C type casts and addition precedence

Cheery picture Cheery · Jul 28, 2010 · Viewed 8.4k times · Source

What's the precedence in the next expression?

item = (char*)heap + offset;

Is it (char*)(heap + offset) or ((char*)heap) + offset?

Answer

Jacob picture Jacob · Jul 28, 2010

Cast trumps binary addition according to the precedence table.

Precedence Table