C type casts and addition precedence

Viewed 10725

What's the precedence in the next expression?

item = (char*)heap + offset;

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

4 Answers

The cast is done first, since it has a much higher precedence.

You can look that up in the C precedence table: C precedence table

Related