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 will be the output of x++ + ++x?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
Explain the Difference between the New and Malloc keyword.
what is difference between ANSI structure and C99 Structure?
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above
What are valid operations on pointers?
How to write a program for swapping two strings without using 3rd variable and without using string functions.
How do you determine whether to use a stream function or a low-level function?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
simple c program for 12345 convert 54321 with out using string
Can we change the value of #define in c?
what is the advantage of software development