gaurav kaushik
Answered On : Oct 26th, 2006
in static memory allocation memory is assigned at compile timefor ex int arr[] = {1,2,3};compiler will allocate memory for 3 integer at compile.whil in dynamic memory allocation memory is assigned at run time. ex malloc(20)compiler will simply see its a function and is argument.while th memory will be allocated at run time.
Login to rate this answer.
Amareswar
Answered On : Dec 1st, 2006
Static memory is pre-allocated during process mapping into the main memory.
Dynamic memory is allocated on heap space of the process map. Visibility throughout the process with the help of a pointer reference.
Login to rate this answer.
kiran
Answered On : Apr 26th, 2007
main()
{
if(true)
{
int a;
int b;
}
else
{
int c;
int d;
}
getch();
}
here in the above program, memory is allocated at compaliation time .since the size of above program is 4*2=8 bytes...
main()
{
if(true)
{
int a=new int;
int b=new int;
}
else
{
int c=new int;
int d=new int;
}
getch();
}
here in the above progame, memory allocated at dynamically(at run time).since the size of the above progam is 2*2=4bytes...
Login to rate this answer.