0

e.g.

    int a = 3;
    int b = sizeof(++a);
    int c = a;

Is c equal to 3 or 4 as the result? Does the result depend on the specific compiler?

xiaokaoy
  • 1,608
  • 3
  • 15
  • 27
  • There is nothing creative or constructive in this question . The answer could have been easily found out on the SO itself . – 0decimal0 Sep 04 '13 at 04:01

1 Answers1

0

The specification states that the increment operator does NOT take affect when used within a sizeof operator.

This also makes sense from an abstract viewpoint. Specifically, the sizeof operator returns the number of bytes used by an object. While incrementing an integer or even a pointer does NOT change the size of that integer, the ++ operator would mis-lead a new programmer into thinking the size does change.

If interested look-up the topic "side-effects" for more discussion about this subject.

JackCColeman
  • 3,777
  • 1
  • 15
  • 21