explain memory layout of a C program

Answers were Sorted based on User's Feedback



explain memory layout of a C program..

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

explain memory layout of a C program..

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

Post New Answer

More C Interview Questions

write a program to produce the following output; ABCDEFGFEDCBA ABCDEF FEDCBA ABCDE EDCBA ABCD DCBA ABC CBA AB BA A A

17 Answers   ABC, College School Exams Tests,


f() { int a=2; f1(a++); } f1(int c) { printf("%d", c); } c=?

7 Answers   Geometric Software,


1. Write the function int countchtr(char string[ ], int ch); which returns the number of times the character ch appears in the string. Example, the call countchtr(“She lives in NEWYORK”, ‘e’) would return 3.

4 Answers  


Why #include is used in c language?

0 Answers  


Which built-in library function can be used to match a patter from the string?

0 Answers  


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

0 Answers   TCS,


Can a program have two main functions?

0 Answers  


Can we declare a function inside a function in c?

0 Answers  


illustrate the use of address operator and dereferencing operator with the help of a program guys plzzz help for this question

0 Answers  


if a five digit number is input through the keyboard, write a program to calculate the sum of its digits. (hint:-use the modulus operator.'%')

23 Answers  


Convert the following expression to postfix and prefix (A+B) * (D-C)

3 Answers   Satyam,


main() { int i; for(i=0;i<5;i++) printf("%d",1l<<i); } why doesn't 'l' affect the code??????

1 Answers  


Categories