c++ program gets segmentation fault
<p>I've been working on some coding and I ran into a segmentation fault. I've tried my best to make it work but I kept failing. Now I am asking for help. This is my code:</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

int main()
{

    string symbols = "ABCDEFGHIJKLMNOPRSTUVYZ_";

    int sim, a = 0;

    sim = symbols.size();

    string temp[sim];

    while(sim &gt; 0)
    {
    sim--;

    temp[sim] = symbols.substr(sim, 1);

    cout &lt;&lt; temp[sim] &lt;&lt; endl;
    }

}
</code></pre>

<p>Well this kinda works but if I do some changes it crashes.</p>

<p>I change:</p>

<pre><code>    while(sim &gt; 0)
    {
    sim--;

    temp[sim] = symbols.substr(sim, 1);

    cout &lt;&lt; temp[sim] &lt;&lt; endl;
    }
</code></pre>

<p>To this:</p>

<pre><code>    while(a &lt; sim)
    {
    a++;

    temp[a] = symbols.substr(a, 1);

    cout &lt;&lt; temp[a] &lt;&lt; endl;
    }
</code></pre>

<p>I get SIGFAULT, I don't really understand that is wrong. I used debugger and it doesn't really show at which line it crashes, it just show this:</p>

<p>Program received signal SIGSEGV, Segmentation fault.</p>

<p>In <code>__gnu_cxx::__exchange_and_add(int volatile *, int) () ()</code></p>
