+ 1

What is the value of c under Linux 64-bits platform?

The following code:https://code.sololearn.com/c2Ce84AhQ3hq/?ref=app I think that the value of c is 2+3=5. Unfortunately it doesn't follow my thinking. So I ask the social media say it evaluation is "2+3*4(because int is 4 bits)". That doesn't make any sense to me. How did that works??

3rd Feb 2021, 4:43 AM
RainStorm
RainStorm - avatar
3 Antworten
+ 2
The key to the problem is that #define is not a function, so you'll not get: ptr=(int*)(long)(a+b); But: ptr=(int*)(long)a+b; That means ptr=(address)long2 + 3 (pointer arithmetic)
3rd Feb 2021, 5:19 AM
Angelo
Angelo - avatar
+ 6
RainStorm an extra set of parentheses will do the trick.
3rd Feb 2021, 5:27 AM
Sonic
Sonic - avatar