static un-initialized variables are stored in BSS-block started by symbols and initialized variables are stored in data section, and not in HEAP section. To this question, preference is given to local variable compared to global variable. if you do objdump -x <exe_name>, and see in the headers you will see 2*4 as size for BSS section.
Bhagwat http://twitter.com/maholdotorg On Tue, Aug 3, 2010 at 6:41 PM, naresh ssn <[email protected]> wrote: > > static int x=3; > int main() > { > static int int x=4; > printf("%d",x); > } > > ans is 4 > > my doubt is all static are placed in heap section so same name one is local > & one is globle how it works > >

