Hi John,
You need to take in account the alignment principle, local variables ( 32-bit ) pushed to the stack are aligned to DWORD :
#include <stdio.h>
#include <windows.h>
int main(int argc, char *argv[])
{
int x=1536;
char t=65;
printf("x=%u , t=%c\n",x,t);
printf("sizeof x=%u ,sizeof=%u\n",sizeof(x),sizeof(t));
return 0;
}
Output :
x=1536 , t=A
sizeof x=4 ,sizeof=1
Disassembling the object module :
_main PROC NEAR
push 65 ; 4 bytes
push 1536 ; 4 bytes
push offset @1023
call _printf
add esp, 12
push 1
push 4
push offset @1025
call _printf
add esp, 12
xor eax, eax
ret
_main ENDP
The char and int values are occupying the same size, 4 bytes ( =DWORD )