阅读描述您的代码行为的注释:
#include <stdio.h>
int main (void) {
int x = 5;
double y = 6;
int z = x+y; // 5 (int, 4 bytes) + 6 (double, 8 bytes)
// converting `int` to `double` when adding them ()
// 5.0 (double, 8 bytes) + 6.0 (double, 8 bytes)
// 11.0 (double, 8 bytes)
// But! `z` is of type `int`, so it will not convert to `double`
// Then 11.0 converts to 11 because `z`... is of type `int`!
/// read "Double-precision floating-point format" and you'll see why.
// So, z = 11 (`z` is of type `int`, so it's size is *4* bytes )
// Here is your 4 bytes instead of 8! ;)
printf("size of z = %d bytes",sizeof(z));
return 0;
}