In the following code I'm providing size of array at run time.
#include <stdio.h>
int main()
{
int i;
scanf("%d",&i);
int a[i];
}
Please tell me the difference between the code above and code using malloc()
.
I know that array store is on the stack and dynamic memory (malloc
, calloc
etc) is on the heap.
So is my code functioning similar to malloc
? If not, please explain.