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 1 of 2.
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)
Likita shetty said:
1 decade ago
what is the difference between heap and stack .. i know stack works on the principle of last in first out and what about heap ?
Saurabh said:
1 decade ago
Heap area consist of hash codes .i.e. addreses while stack may or may not be.
Dev. said:
1 decade ago
malloc and calloc allocates memory in heap.
Purva said:
1 decade ago
Like stack is First in first out, how does heap work ?
Reena said:
1 decade ago
The main difference between stack and heap is, Stack is last in first out. But heap is not related to that that concept. Heap is related to dynamic memory allocation. Heap is the area where the elements are stored in a dma. All the malloc() , realloc() and calloc() are related to dynamic memory alloction concepts.
Vaishu said:
1 decade ago
malloc() is dynamic memory allocation. So it is stored in Heep memory.
Mahesh karle said:
1 decade ago
malloc and calloc are always allocates memory in heap.
Amol said:
1 decade ago
What is difference between malloc() & calloc() (4 points)?
JITENDRA KUMAR said:
1 decade ago
malloc takes single argument. But calloc function takes two arguments.
malloc initialize memory chunks with garbage value but calloc initialize with zero.
Both are stored in heap memory and allocate memory at dynamic time.
For security purpose malloc is not prefere than calloc.
malloc initialize memory chunks with garbage value but calloc initialize with zero.
Both are stored in heap memory and allocate memory at dynamic time.
For security purpose malloc is not prefere than calloc.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers