title: Scope vs. Lifetime of Variable
body: <p>What is the relation between the scope and the lifetime of a variable?
  If a variable is out of scope, is the memory of it allowed to be overwritten by another variable, or is the space reserved until the function is left.</p>
  
  <p>I am aksing because I want to know whether the code below actually works, or whether it can be that *p might be undefined</p>
  
  <pre><code>foo() {
    int *p;
    {
      int x = 5; 
      p = &amp;x;
    }
    int y = *p;
  
  
  }
  </code></pre>