C Programming - Memory Allocation - Discussion
Discussion Forum : Memory Allocation - True / False Questions (Q.No. 2)
2.
malloc() allocates memory from the heap and not from the stack.
Discussion:
14 comments Page 2 of 2.
E.senthil kumar.,bca.,(mca) said:
1 decade ago
Stack has some static order, so we can't allocate dynamically, so malloc follow heap.
Hitesh AGARWAL said:
10 years ago
If Memory is allocating at compile time (static allocation) then stack is use.
But if Memory is allocating at Run time (dynamic allocation) then Heap is use. And malloc is Dynamic allocation so it's clear that it is use heap.
But if Memory is allocating at Run time (dynamic allocation) then Heap is use. And malloc is Dynamic allocation so it's clear that it is use heap.
Ziddi said:
9 years ago
Thank you @Hitesh.
Bala Aathikesavan said:
2 years ago
Because dynamic memory allocation always takes place in the heap.
Thats why malloc takes place in a heap because malloc comes under the topic of dynamic memory allocation where data will be allocated in heap without any order or randomly.
Thats why malloc takes place in a heap because malloc comes under the topic of dynamic memory allocation where data will be allocated in heap without any order or randomly.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers