DYNAMIC MEMORY ALLOCATION (DMA)
In programming we use some variables and to store those variables we used memory space to allocate some space for that variable .when we are using array we can use or allocate memory space dynamically means to allocate contiguous memory space during the program execution .means the way to reserve memory address at run time is called dynamic memory allocation or in short it refers as DMA. There are two functions used to allocate: Malloc():used for allocation of memory space at run time Syntax: int *ptr; Ptr=(int*)malloc(n*sizeof(int)); · Here ptr accepts the base address returned by the given statement. · Malloc is the function used for allocation of memory space. · N stands for number of elements · Sizeof return the size of the data type enclosed in the bracket Calloc(): is s...
Comments
Post a Comment