Better, but you still need to call a function to work out how much space you needed.
There is no relationship between the order in which you declare local variables, and the relative positions of them on the stack.
Or there's this way
Code:
void foo ( int a ) {
int c = 2;
printf("hello %d %d\n",a,c);
}
_foo:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
movl $2, -4(%ebp)
movl -4(%ebp), %eax
movl %eax, 8(%esp)
movl 8(%ebp), %eax
movl %eax, 4(%esp)
movl $LC0, (%esp)
call _printf
leave
ret
Use "gcc -S" to compile your code, then look for the size adjustment for %esp.