I have a C program which does queue operations using an array. In that program, they increment a variable inside array. I can't understand how that works. So, please explain these operations:
array[++i];
array[i++];
Please explain these operations.
array[++i];
- first increments i
, then gives you element at the incremented index
equivalent to:
++i; // or i++
array[i];
array[i++];
- also first increments i
, but postfix operator++
returns i
's value before the incrementation
equivalent to:
array[i];
++i; // or i++
They increment a variable inside array.
No, they don't. You could say they increment i
within the call to array subscript operator.