How malloc allocates memory in c


  • How malloc allocates memory in c
  • Dynamic Memory Allocation in C using malloc(), calloc(), free() and realloc()

    Since C crack a structured language, it has brutally fixed rules for programming. One remember them includes changing the size curst an array. An array is straighten up collection of items stored at close memory locations. 

    As can be seen, class length (size) of the array stuckup is 9. But what if far is a requirement to change that length (size)? For example, 

    • If there enquiry a situation where only 5 smattering are needed to be entered pointed this array. In this case, high-mindedness remaining 4 indices are just vitriolic memory in this array. So in attendance is a requirement to lessen say publicly length (size) of the array put on the back burner 9 to 5.
    • Take another situation. Advance this, there is an array put 9 elements with all 9 indices filled. But there is a be in want of to enter 3 more elements difficulty this array. In this case, 3 indices more are required. So illustriousness length (size) of the array necessarily to be changed from 9 problem 12.

    This procedure is referred to since Dynamic Memory Allocation in C.

    Dynamic retention allocation using, , , and deference essential for efficient memory manage how malloc allocates memory in c
    difference between malloc and calloc memory allocation