昨天我接受采访时面试官问我存储变量的存储类.
我的回答是战争:
Local Variables are stored in Stack.
Register variables are stored in Register
Global & static variables are stored in data segment.
The memory created dynamically are stored in Heap.
Run Code Online (Sandbox Code Playgroud)
他问我的下一个问题是:他们为什么要存储在那些特定的记忆区域?为什么Local variable 没有存储register(虽然我需要auto在我的程序中经常使用变量)?或者为什么not要存储全局变量或静态变量stack?
然后我一无所知.请帮我.
c ×1