title: Internal static variables in C, would you use them?
body: <p>In C you can have external static variables that are viewable every where in the file, while internal static variables are only visible in the function but is persistent</p>
  
  <p>For example:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void foo_bar( void )
  {
          static counter = 0;
          printf("counter is %d\n", counter);
          counter++;
  }
  int main( void )
  {
          foo_bar();
          foo_bar();
          foo_bar();
   return 0;
  }
  </code></pre>
  
  <p>the output will be</p>
  
  <pre><code>counter is 0
  counter is 1
  counter is 2
  </code></pre>
  
  <p>My question is why would you use an internal static variable? If you don't want your static variable visible in the rest of the file shouldn't the function really be in its own file then?</p>