局部变量和static变量的区别
static int a ; int b; scanf_s("%d %d",&a,&b); 01374212 lea eax,[b] 01374215 push eax 01374216 push offset a (0137A13Ch) 0137421B push offset string "%d %d" (01377BCCh) 01374220 call _scanf_s (0137137Fh) 01374225 add esp,0Ch printf("%d",a); 01374228 mov eax,dword ptr [a (0137A13Ch)] 0137422D push eax 0137422E push offset string "%d" (01377BD4h) 01374233 call _printf (01371375h) 01374238 add esp,8 printf("%d",b); 0137423B mov eax,dword ptr [b] 0137423E push eax 0137423F push offset string "%d" (01377BD4h) 01374244 call _printf (01371375h)
根据汇编代码可以看到,局部变量的地址是在栈中,而static变量的地址是在全局变量区里面。