in Programming in C
427 views
0 votes
0 votes

Please explain points in short, and intuition behind its working.

​​

in Programming in C
427 views

4 Comments

@Shubhanshu 

in your 2nd statement i.e S2, 

are we allocating dynamic memory for a function call ? then why its not in heap but in stack ? 

function calls are stored in stack i agree but i am not getting its relationship with dynamic allocation i.e "new".

please explain.

0
0
I mean to say that, suppose u call a function fun() and inside it's body we have declaration.

int *p = new int(20);

So through this we have proved that stack allocation support pointers. And through:-

delete(p);

We showed that we can deallocate space at run time too.
1
1

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
4
Somdatta Sen asked in Programming in C Feb 9, 2019
400 views
Somdatta Sen asked in Programming in C Feb 9, 2019
400 views