Describe about storage allocation and scope of global, extern, static, local and register variables?

Showing Answers 1 - 4 of 4 Answers

yogeshpanda

  • Sep 21st, 2005
 

Type             Storage allocation             Scope

local               In Stack                         Local to the block              

Resister           In register                       Local to the block

global              In Heap                          Programs scope

Extern             In heap                           program scope (global) 

  Was this answer useful?  Yes

SKPasu

  • Aug 19th, 2010
 

Everybody knows about the scope, but the real thing is for the storage allocation:-

Memory is devided into four segements namely stack, heap, data, code segments.

Local Variables are stored in Stack.
The memory created dynamically are stored in Heap
Extern, Global & static variables need to retain their values so are stored in data segment.
The C program instructions get stored in code segment 
Register variables are stored in Register.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions