title: What is the Static Global Variable Purpose?
body: <p>I know that the variable that is declared <code>static</code> only has scope in the file in which it is declared whereas the variable declared without <code>static</code> can be accessed from other files using an extern declaration.</p>
  
  <p><strong>but Is it true that the <code>static</code> "Global" is to make the variable retain the last assigned value. Like the Static Local Purpose ?</strong></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void func() {
    static int x = 0; // x is initialized only once across three calls of func()
    printf("%d\n", x); // outputs the value of x
    x = x + 1;
  }
  
  int main(int argc, char *argv[]) {
    func(); // prints 0
    func(); // prints 1
    func(); // prints 2
    return 0;
  }
  </code></pre>