
A C program can have the following kinds of variables.

1) Global variables:
    a) default global variables
       i) initialized
      ii) uninitialized
    b) static global variables
       i) initialized
      ii) uninitialized
    c) external global variables

2) Local variables:
    a) automatic local variables
       i) initialized
      ii) uninitialized
    b) static local variables
       i) initialized
      ii) uninitialized
    c) formal parameters
    d) external local variables

3) Dynamic variables


NOTE: For each of the above kinds of variables, you should be able to
      specify its scope and its lifetime.

------------------------------------------------------------------------

A running C program is made up of the following parts.

1) Code:
    a) your code
    b) library code
    c) operating system code

2) Data:
    a) initialized data segment
    b) uninitialized data segment
    c) read-only data segment
    d) stack
    e) heap


NOTE: Each kind of C variable mentioned in the first part is stored
      in one of the 5 data areas listed just above. You should be able
      to specify which kind of variable is stored in which kind of data
      area.

-------------------------------------------------------------------------

Here are the steps involved in converting a C source code file into a
running program. Along with each step is listed some tools that you can
use to observe the result of that step. Using these tools, you can take
a simple C program and observe into which data area listed above each of
the kinds of variables listed in the first part above gets stored.


               C Source Code  -------> text editor
                     |
                     |
                     |  Compiler
                     |
                     |
             Assembly Source Code  --> text editor
                     |
                     |
                     |  Assembler
                     |
                     |
                  obj file  ---------> objdump (comes with gcc)
                     |                 Dumpbin (comes with Visual Studio)
                     |
                     |
                     |   Linker
                     |
                     |
                  exe file  ---------> Depends  (www.dependencywalker.com)
                     |                 PEBrowse (www.smidgeonsoft.com)
                     |                 objdump
                     |                 Dumpbin
                     |
                     |   Loader
                     |
                     |
                runtime image  ------> Visual Studio debugger
                                       Process Viewer   (www.prcview.com)
                                       Process Explorer (www.sysinternals.com)
                                       PEBrowseDbg      (www.smidgeonsoft.com)
                                       Process Walker   (from MS Platform SDK Examples)


NOTE: One interesting thing to note is that at every step of the above
      process you can use at least one of the tools listed to get an
      "assembly language" listing of the result of that step. Take a
      simple program, look at its assembly language at each of these
      steps and notice how the assembly language is modified a bit at
      each step. In particular, each step resolves more symbols into
      addresses than the previous step.
