Following is the memory layout of a typical C program:
Now, consider the C program below:
#include <stdio.h>
int iglobal = 10;
int uglobal;
int main(void)
{
static int i;
int j;
return 0;
}
Question #14: Where does the variable i go in memory?
Options:
A) Heap
B) Uninitialized data (bss)
C) Stack
D) Initialized data
Solution: All static variables have the scope of the lifetime of the program, so they have to go to data segment. Since it is uninitialized, it goes to bss. So option B is the correct one.
