Weird auto-initialization behavior
<p>I learned that auto-variables aren't initialized to zero. So the following code will behave correctly and prints random numbers on the screen:</p>

<pre><code>#include &lt;iostream&gt;
using std::cout;
using std::endl;

void doSomething()
{
  int i;
  cout &lt;&lt; i &lt;&lt; endl;
}

int main()
{
  doSomething();
}
</code></pre>

<p>But why won't this snipped behave in the same way ?</p>

<pre><code>#include &lt;iostream&gt;
using std::cout;
using std::endl;

void doSomething()
{
  int i;
  cout &lt;&lt; i &lt;&lt; endl;
}

int main()
{
  int j;
  cout &lt;&lt; j &lt;&lt; endl;
  doSomething();
}
</code></pre>

<p>This snippet shows:</p>

<pre><code>0
0
</code></pre>

<p>Does anyone know why "j" and "i" were suddenly initialized to zero here?</p>
