C Programming: Understanding sizeof Operator with Pre-Increment
The output of this program will be 'i=5 j=4'.
In the statement j = sizeof(++i + ++i)
, we first evaluate the expression ++i + ++i
.
Since i
is initially 3, the first ++i
increments i
to 4, and the second ++i
increments i
to 5.
Then, ++i + ++i
is evaluated as 4 + 5, which is 9.
The sizeof
operator then returns the size of the expression, which in this case is 4 (the size of an integer).
Finally, the value of j
is assigned as 4, and the values of i
and j
are printed.
原文地址: http://www.cveoy.top/t/topic/p3Lj 著作权归作者所有。请勿转载和采集!