"foo++;" crashes my prime number finder
<p>Today I tried to do program that will trying to find prime numbers, add them to array:"arraiki" and then check if it works properly by comparing array:"arraiki" with auto filled array:"myInput".
But unfortunately it crashes itself when im trying to change value of temp, that is index of array:"arraiki".</p>

<p>Mini-version.</p>

<pre><code>int temp = 0;

{

  loop, if...

  arraiki[temp] = i;

  temp++;

}
</code></pre>

<hr>

<p>Whole code:</p>

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

using namespace std;

string prime(int &amp;range)

{
string answer="";

for (int i=2; i&lt;range; i++)
{
    if (range%i==0) answer = "NOPE";
}

if(answer=="NOPE") return "NAH";
else return "TRUTH";
}



int main()
{

int arraiki[] = {};
int myInput[] = {2,5,7};
int temp = 0;

for (int i = 2; i&lt;100; i++)
{
    if(prime(i)=="TRUTH")
    {
        arraiki[temp] = i;
/// --&gt; causes problem     temp++;

/*error.log()*/ cout &lt;&lt; "temp is: " &lt;&lt; temp &lt;&lt; " value of arraiki is:     " &lt;&lt;arraiki[temp] &lt;&lt; " and i: " &lt;&lt; i &lt;&lt;  endl;
    }

}



/// SOON ™
/*
for (int =0; i&lt;(sizeof(arraiki)/sizeof(arraiki[0])); i++)
{
     if(arraiki[i]==myInput[i])

                            cout &lt;&lt; "OK AT: " &lt;&lt; i &lt;&lt; endl;

            else
                            cout &lt;&lt; "SMTH WENT WRONG AT: " &lt;&lt; i &lt;&lt; endl;
}
*/
return 0;

}
</code></pre>

<hr>

<p>Error "log" with temp++; turned OFF</p>

<p>temp is: 0 value of arraiki is:     2 and i: 2</p>

<p>temp is: 0 value of arraiki is:     3 and i: 3</p>

<p>temp is: 0 value of arraiki is:     5 and i: 5</p>

<p>temp is: 0 value of arraiki is:     7 and i: 7</p>

<p>temp is: 0 value of arraiki is:     11 and i: 11</p>

<p>temp is: 0 value of arraiki is:     13 and i: 13</p>

<p>temp is: 0 value of arraiki is:     17 and i: 17</p>

<p>temp is: 0 value of arraiki is:     19 and i: 19</p>

<p>temp is: 0 value of arraiki is:     23 and i: 23</p>

<p>temp is: 0 value of arraiki is:     29 and i: 29</p>

<p>(...)</p>

<p>temp is: 0 value of arraiki is:     97 and i: 97</p>

<p>So, It shows prime values properly.</p>

<p>PS: What I could do better? Please be Honest.</p>