C - Dynamic Memory Allocation
Structure and Linked List with C Programming in Tamil
C Dynamic Memory Allocation
- In C- Programming the memory will be allocated at runtime called as dynamic memory allocation.
- Generally, the malloc, calloc and realloc are the three functions used to manipulate memory in C-Programming..
Dynamic Memory Allocation functions :
Malloc() Functions :
- In C-Programming the malloc function is used to allocate space in memory during the execution of the program.
Calloc() Function :
- The calloc() function is similar to malloc() function. The calloc () initializes the allocated memory to zero.
Realloc() Function :
- In C-Programming the realloc() function modifies the allocated memory size by malloc() and calloc() functions to new size.
Free() Function :
- In C-Programming the free () function frees the allocated memory by malloc (), calloc (), realloc () functions and returns the memory to the system.
Static vs Dynamic Memory Allocation
|Static Memory Allocation||Dynamic Memory Allocation|
|Memory is allocated at compile time.||Memory is allocated at run time.|
|Memory can't be increased while executing program.||Memory can be increased while executing program.|
|Used in array.||Used in linked list.|
|Less efficient||More efficient|