Dynamic Memory Allocation in C

This “Dynamic Memory Allocation in C” post explains clearly what is the importance of Dynamic memory and how to allocate memory memory dynamically in C programming.


 

Dynamic Memory Allocation:

  • C-language is having pre-defined library.
  • Library contains number of pre-define functions.
  • All the pre-defined functions divided into header files.
  • All the related functions grouped together and placed in a header file.

 

C Library with Header files

 

stdlib.h having pre-defined functions to Allocate & De-allocate the memory

malloc() : Used to allocate the memory dynamically for structures.
calloc() : Used to allocate the memory to arrays
realloc() : Used to increase the decrease the size of array which as allocated using calloc() function.
free() : To destroy the memory which has allocated dynamically.

Share this