C Memory Management

C Memory Management


C Programming Language provides the following dynamic allocation and de allocation function –

  • malloc()
  • calloc()
  • realloc()
  • free()

malloc,calloc and realloc is used for memory allocation and delocation is achieved by the use of free function.

Allocating A Block of Memory-malloc()

The malloc() function allocates the memory at run time whenever required. It allocates the memory block with required number of contiguous bytes in the memory and returns the pointer to the first byte(base address) or null if there is some error occur.