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 |
HOW DO YOU HANDLE EXCEPTIONS IN C?
Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?
Why ordinary variable store only one value
Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.
Write a program that his output 1 12 123
List some of the dynamic data structures in C?
I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?
what is the flow of execution in cprogram? ex:printf();,scanf();
What is merge sort in c?
write a program that eliminates the value of mathematical constant e by using the formula e=1+1/1!+1/2!+1/3!+
What is true about the following C Functions a.Need not return any value b.Should always return an integer c.Should always return a float d.Should always return more than one value.
What are c identifiers?