title: how do static variables inside functions work?
body: <p>In the following code:</p>
  
  <pre><code>int count(){
      static int n(5);
      n = n + 1;
      return n;
  }
  </code></pre>
  
  <p>the variable <code>n</code> is instantiated only once at the first call to the function.</p>
  
  <p>There should be a flag or something so it initialize the variable only once.. I tried to look on the generated assembly code from gcc, but didn't have any clue.</p>
  
  <p>How does the compiler handle this?</p>