In C language, there are two types of memory allocations to any variable.
generally in normal programming, we define and declare the variable with the data type and storage class of the variable and the memory is allocated to the variable. This is called static memory allocation.
But in certain cases where in we don't know about how many variables we are going to use and how much of memory is to be allocated, we opt for at the instant memory allocation during the execution of the program which is called as Dynamic Memory allocation.
for dynamically allocating memory, we make use of
malloc,calloc and realloc functions.
coming to the memory, In static memory allocation (SMA),the memory is allocated in STACK of the RAM and in Dynamic Memory Allocation, the memory is allocated in HEAP of the RAM.
generally in normal programming, we define and declare the variable with the data type and storage class of the variable and the memory is allocated to the variable. This is called static memory allocation.
But in certain cases where in we don't know about how many variables we are going to use and how much of memory is to be allocated, we opt for at the instant memory allocation during the execution of the program which is called as Dynamic Memory allocation.
for dynamically allocating memory, we make use of
malloc,calloc and realloc functions.
coming to the memory, In static memory allocation (SMA),the memory is allocated in STACK of the RAM and in Dynamic Memory Allocation, the memory is allocated in HEAP of the RAM.
http://www.notes99.com/2013/11/dynamic-memory-allocation.html
ReplyDelete