A Little about the blog.....

This blog contains all the interview questions that i face during my interviews with various MNC's. I am trying to post the solutions for almost all the questions and i have covered few important topics which would be frequent topics in interviews. I hope the blog would be useful not only for the job aspirants but also to the one who tries to upgrade his/her knowledge in C and Embedded concepts......

please enter your mail address in the above mail address box to get the immediate updates of the new interview questions.....

Wednesday, November 16, 2011

Difference between Static Memory Allocation and Dynamic Memory Allocation

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.

1 comment:

  1. http://www.notes99.com/2013/11/dynamic-memory-allocation.html

    ReplyDelete