Discussion
In C runtime environment, which one of the following is stored in heap?
Answer: C
The item stored in the heap is a dynamically allocated array of integers created using malloc().
In a C program the heap is the region managed by malloc(), calloc(), realloc() and free(). Memory obtained from malloc() stays allocated until it is freed, independent of function calls, which is exactly what the heap is for.
A static variable declared inside a function lives in the static data segment (.data or .bss), not on the heap. An ordinary array declared inside a function is an automatic variable on the stack, and the return address of a function is pushed onto the stack as part of its activation record.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development