Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Why does integer variable int occupy 4 bytes in C language? Float is 4 bytes? Double takes up 8 bytes? (Can you elaborate? )
Why does integer variable int occupy 4 bytes in C language? Float is 4 bytes? Double takes up 8 bytes? (Can you elaborate? )
How many bytes an int occupies is determined by the compiler, and the ANSI standard defines that an int occupies 2 bytes.

TC is based on ANSI standard, and int is 2 bytes.

You can try. Printf ("%d ",sizeof(int));) in TC; The result is 2;

But in VC, an int takes up 4 bytes, while in VC,

printf("%d ",sizeof(int));

cout & lt& ltsizeof(int); The results are all 4.

Different compilers have different regulations.

The same is true for float and double, which occupy different bytes in different compilers.