How does sizeof wоrk in this case?

An int is 4 byte long. You are are passing the sizeof operatore an int Array of length 2. To store an int Array of 2 you need 2x4 = 8 Bytes.


increments the value of i from 1 to 2 before it is used. That's why your output is 8 and 2.

At the time int[++i] is evaluated, i initially has the value 1. So int[++i] evaluates to int[2], i.e. an array of int of size 2.

Assuming an int is 4 bytes on your system, this array is 8 bytes in size.