Stack memory allocation
<p>It is being said that local variable will be allocated and deallocated automatically when function ends in C/C++.</p>

<p>According to my understanding, when having been deallocated, the value held by local variable also be destroyed!!! Please correct me if i'm wrong</p>

<p>Consider following code:</p>

<pre><code>void doSomething(int** num)
{
  int a = 10;
  *num = &amp;a;
} // end of function and a will be destroyed

void main()
{
  int* number;
  doSomething(&amp;number);
  cout &lt;&lt; *number &lt;&lt; endl;  // print 10 ???
}
</code></pre>

<p>Could anybody clarify for me?     </p>
