Dynamic Memory Allocation
C allows general purpose dynamic memory allocation on the heap, restricted only by the amount of memory available at run time
There are three predefined functions for this:(in /usr/include/stdlib.h)void * malloc(num_bytes_to_allocate);void * calloc(num_of_obj, size_of_obj);void * realloc(old_ptr, new_size_in_bytes);
If memory allocation fails, these functions return a NULL pointer.
Since these functions return a pointer to void, when allocating memory use conversion:int *pi = (int *) malloc(5*sizeof(int)); /* or: */int *pi = (int *) calloc(5,sizeof(int));pi = (int *) realloc(pi, 10*sizeof(int));