explain memory layout of a C program
Answers were Sorted based on User's Feedback
Answer / ravindra garg
(Higher Memory Address)
STACK -->Func arguments and return val(locals)
'
'
|
^
'
HEAP --> Dynamic Data
BSS --> Uninitialized Data
(Global and static default to zero)
DATA SEGMENT --> Initilialised data
(Global and static with init vals)
CODE SEGMENT --> Instructions
[Lower Memory Address]
| Is This Answer Correct ? | 38 Yes | 3 No |
Answer / pankaj saraf
Memory Layout consists following segments where data/text
are managed:
1) Text Segment : Consists serial of instruction.
2) Data Segment : Consists, Data default or defined class
specifier
i) Stack Segment : Area where the current function data
is managed.
ii) Heap Segment : Area where dynamically allocated data
stored.
3) BSS Segment: For uninitialized data.
Data segment is actually contains the static data which is
decided on the compile time. Rest of Area is used by Stack
and Heap which is actually modified run time. Stack grows
from higher address to lower Address. Heap grow just
opposite to the stack.
Anything else you guys are invited to add. :)
| Is This Answer Correct ? | 36 Yes | 7 No |
Can you define which header file to include at compile time?
what is the advantage of function pointer
16 Answers CMC, CS, Freshdesk, L&T, LG Soft, Matrix, TCS,
How can I generate floating-point random numbers?
write a program to print %d ?
What is the most efficient way to count the number of bits which are set in a value?
Explain the difference between exit() and _exit() function?
When should the register modifier be used? Does it really help?
whats the use of header file in c?
What is the meaning of this decleration? unsigned char (*pArray[10][10]); please reply.
Write a program to print “hello world” without using semicolon?
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.
Differentiate fundamental data types and derived data types in C.