Global and Local Variables

C knows two basic types of variables with different scope:

  1. Global variables are defined outside of functions on module level (except static, see below)jjjjjjjj

  2. Local variables are defined within functions

 

   int global;       // outside function

   void someFunction(void) 
   {
     int local;     // within function
   }