C programming
June 3, 2026 1 min read

Dynamic memory allocation in C programming

HS
HEMANT SINGH
Technical Writer & Educator

malloc(Memory allocation)

Allocate dynamic memory.

p = (int *) malloc(n* sizeof(data_type))

calloc(Contigous allocation)

Allocate dynamic memory.

p = (int *) calloc(n, sizeof(data_type))

 

realloc(Reallocation)

Resize the preallocated memory means it will extends the dynamic memory.

p = (int * ) realloc (p, sizeof(data_type)*n)

 

free()

Free allocated memory.

free(p)