Examples with local variables

  void function(void)
   {
      int local = 0;          // local (automatic) variable allocated on stack of function 
      static int foo = 0;     // declaration and initialization of foo
      foo++;                  // every time the function is called foo would
                              // be incremented 
   }                          // end of function. "local" would disappear. foo stays.

   function();                // first call to function, foo is 1, local is 0
   function();                // second call, foo is 2, local is 0