Unhandled exception at 0x012B1CA9
<p>I am new to C++ and am trying to build a simple program that with the users input to proceed will generate a random left or right. I had the program working correctly until I added in the array to try and store each item as I have to output them as soon and the user would like to exit the loop. The program seems to compile fine but at run time I receive "Unhandled exception at 0x012B1CA9" Any help would be greatly appreciated. </p>

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

int main()
{

int userSelection = 1;
const int MAX = '100';
int randNum(0);
int one (0);
int two (0);
int total(0);
int sel[MAX];

do
{
    cout &lt;&lt; "Press 1 to pick a side or 0 to quit: ";
    cin &gt;&gt; userSelection;



    for (int i = 1; i &lt; MAX; i++)
    {
        srand(time(NULL));
        sel[i] = 1 + (rand() % 2);

        if (sel[i] == 1)
        {
            cout &lt;&lt; "&lt;&lt;&lt;--- Left" &lt;&lt; endl;
            one++;
            total++;
        }
        else
        {
            cout &lt;&lt; "Right ---&gt;&gt;&gt;" &lt;&lt; endl;
            two++;
            total++;
        }
    }


} while (userSelection == 1);

cout &lt;&lt; "Replaying Selections" &lt;&lt; endl;
for (int j = 0; j &lt; MAX; j++)
{
    cout &lt;&lt; sel[j] &lt;&lt; endl;
}

cout &lt;&lt; "Printing Statistics" &lt;&lt; endl;
double total1 = ((one / total)*100);
double total2 = ((two / total)*100);
cout &lt;&lt; "Left: " &lt;&lt; one &lt;&lt; "-" &lt;&lt; "(" &lt;&lt; total1 &lt;&lt; "%)" &lt;&lt; endl;
cout &lt;&lt; "Right: " &lt;&lt; two &lt;&lt; "-" &lt;&lt; "(" &lt;&lt; total2 &lt;&lt; "%)" &lt;&lt; endl;

system("pause");
return 0;
};
</code></pre>