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 |
What is function definition in c?
difference between my-strcpy and strcpy ?
3 Answers Geometric Software, IIM, Infosys,
What is the purpose of main() function?
DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?
why arithmetic operation can’t be performed on a void pointer?
value = 0xabcd; for (loop = 1; (value >> 1) & 1 | loop & 1; loop++) { foo(); if (loop & 1) value >>= 1; } how many times is foo() executed?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
main() { int x=5; printf("%d %d %d\n",x,x<<2,x>>2); } what is the output?
What are the different pointer models in c?
how many key words availabel in c a) 28 b) 31 c) 32
What are register variables in c?
What is time null in c?