≡ Menu

What is dynamic memory allocation Explain in brief

You are Here: Home > Computer Subjects > Programming in C Language > …

What is dynamic memory allocation Explain in brief.

Ans. In computer science, dynamic memory allocation is the process of allocating the memory of computer storage during the run-time of that program. It is also known as heap-based memory allocation.

To allocate memory we must have a pointer so we can know where the memory will be at when it gets allocated. See the code example:

char *str = (char *)malloc(40); // allocate memory for a 40 character string

Heap memory is allocated in a more complex way than stack memory.
Like stack-allocated memory, the underlying system determines where to get more memory – the programmer doesn’t have to search for free memory space.


Click Here to Find Latest Jobs and Current Affairs

{ 0 comments… add one }

Leave a Comment