Difference between static and dynamic

In Dynamic Memory Allocation, memory is allocated at run time. Whereas in Static Memory Allocation, memory is allocated at compile time.
Example :

//Static allocation:
int a[20];

//Dynamic allocation
int *ptr;
ptr=(int *)malloc(sizeof(int)*20);

Post a Comment

0 Comments