very strange C++ error
<p>I have encountered a very strange problem when I am writing code, Here is my C++ code:</p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{
    int qnum;
    cin &gt;&gt; qnum;
    int series[3];
    cin &gt;&gt; series[3];
    cout &lt;&lt; qnum;
}
</code></pre>

<p>For example, If I input 2 for qnum and 5 for series[3], The value of qnum will be overridden in the last line of code.This problem will only occurs when the input for series is 3. The only solution for new is add "static" attribute to qnum, Like this: </p>

<pre><code>#include &lt;iostream&gt;
using namespace std;

int main()
{
    static int qnum;
    cin &gt;&gt; qnum;
    int series[3];
    cin &gt;&gt; series[3];
    cout &lt;&lt; qnum;
}
</code></pre>

<p>Any ideas?</p>
