title: Where is local pointer stored in memory?
body: <p>I am beginner in C. I have one program as below:</p>
  
  <pre><code>int main()
  {
      char* func();
      char *c;
      c = func();
      printf("%s", c);
  }
  
  char* func()
  {
      char *ptr = "OK";
      return ptr;
  }
  </code></pre>
  
  <p>As we all know, <code>ptr</code> is a local variable of <code>func()</code> and is a pointer. The scope is local.
  But when <code>ptr</code> is returned to the caller, <code>main</code>, it is still valid and when <code>c</code> is printed, it prints "OK".</p>
  
  <p>How is this possible? In which memory segment is <code>ptr</code> stored; stack, or heap?</p>