Dynamic Memory Allocation
Dynamic Memory Allocation
2. calloc( ) :
calloc( ) function is also like malloc( ), but calloc( ) initializes the
allocated memory to
zero.
3. realloc( ) :
realloc ( ) function modifies the allocated memory size by malloc( )
and calloc( ) functions to new size.
If enough space doesn’t exist in memory of current block to extend,
new block is allocated for the fullsize of reallocation, then copies the
existing data to new block and then frees the old block.
4. free ( ) :
free ( ) function frees the allocated memory by malloc ( ) and calloc ( )
functions and returns the memory to the system.
Example: