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

what is diffrence between string and character array?

1 Answers  


The difference between printf and fprintf is ?

0 Answers   Baan Infotech,


Is this program statement valid? INT = 10.50;

0 Answers  


Look at the Code: #include<string.h> void main() { char s1[]="abcd"; char s2[10]; char s3[]="efgh"; int i; clrscr(); i=strcmp(strcat(s3,ctrcpy(s2,s1))strcat(s3,"abcd")); printf("%d",i); } What will be the output? A)No output B) A Non Integer C)0 D) Garbage

7 Answers   Accenture,


Write a program in c to print * * * * * *******

1 Answers  






What is uint8 in c?

0 Answers  


What does emoji p mean?

0 Answers  


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

0 Answers  


What are variables c?

0 Answers  


How can you read a directory in a C program?

0 Answers  


Explain the use of #pragma exit?

0 Answers  


can we store values and addresses in the same array? explain

3 Answers   TCS,


Categories