+ 2

Why does sizeof(x++) not increment x? -

12th Sep 2020, 5:06 PM
RAJ PATIL
RAJ PATIL - avatar
6 ответов
+ 2
HBhZ_C I don't think this is what happens. sizeof is evaluated at compile time so the x++ has no effect at all, it's simply ignored at runtime. This means both sizeof(x++) and sizeof(++x) are treated like a simple sizeof(x).
12th Sep 2020, 6:17 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 1
This statement will be evaluated to: sizeof(x); x++; So if you display x value now: printf("%d",x);???
12th Sep 2020, 5:12 PM
HBhZ_C
HBhZ_C - avatar
+ 1
HBhZ_C okey okey got it.👍
12th Sep 2020, 5:13 PM
RAJ PATIL
RAJ PATIL - avatar
+ 1
Read about postfix and prefixing in c and c plus plus RAJ PATIL .
12th Sep 2020, 5:19 PM
HBhZ_C
HBhZ_C - avatar
+ 1
Yes Aaron Eberhardt x++ has not effect in sizeof method then outside if x is called it will be affected by last increment.So it will not conserve its first value.Use printf instead of sizeof to test again.
12th Sep 2020, 6:25 PM
HBhZ_C
HBhZ_C - avatar