PanP5
April 12th, 2010, 03:56 PM
A C program is composed of the following pieces:
The Text segment
The Initialized Data Segment
The Uninitialized Data Segment
The Stack
The Heap
The initialized and uninitialized data segment... do those strictly contain the variables declared/initialized in the main function? Is everything declared/initialized inside another function simply stored on the stack?
For example:
int foo()
{
int j = 2;
return j;
}
int main(int argc, char *argv[])
{
int k;
int i = 5;
k = foo();
return 0;
}
Where in the program memory do i,j,and k reside? When does that happen?
The Text segment
The Initialized Data Segment
The Uninitialized Data Segment
The Stack
The Heap
The initialized and uninitialized data segment... do those strictly contain the variables declared/initialized in the main function? Is everything declared/initialized inside another function simply stored on the stack?
For example:
int foo()
{
int j = 2;
return j;
}
int main(int argc, char *argv[])
{
int k;
int i = 5;
k = foo();
return 0;
}
Where in the program memory do i,j,and k reside? When does that happen?