Um die Größe der Variablen mit sizeof()Warum gibt sizeof() 4 Byte statt 2 Byte kurzer Int zurück?
#include <stdio.h>
main()
{
int a = 10,b = 20;
short int c;
short int d = sizeof(c = a+b);
int e = sizeof(c*d); //e holds the value of 4 rather than 2
double f = sizeof(e*f);
printf("d:%d\ne:%d\nf:%lf\n",d,e,f);
}
Warum ist sizeof() Rückkehr der Größe von int statt short int zu drucken, die 2 Bytes zu verstehen?
Siehe auch: [why sizeof (short + short) hat eine andere Größe als sizeof (short)?] (Https://stackoverflow.com/q/24610737/253056) –