title: Having problems with my one-armed bandit game in C++
body: <p>Im currently making a one-armed bandit game and this is what it's supposed to do:</p>
  
  <ul>
  <li>The user should be able to put money into the machine, 50, 100 or 500</li>
  <li>The user should be able to bet money for each game</li>
  <li>After the user have betted money symbols should be randomized in a field like this:</li>
  </ul>
  
  <p>[ o ] [ p ] [ x ]</p>
  
  <p>[ x ] [ x ] [ x ]</p>
  
  <p>[ x ] [ o ] [ x ]</p>
  
  <p>(1 columns/ lines wins 2x money, 2 columns/ lines wins 4x money etc.)</p>
  
  <p>This field should each time be randomized with letters , also a two-dimensional array should be used to represent the gamearea.</p>
  
  <p>I've ran into some problems, basically after I bet some money the game closes and I cant see any errors etc, any help that clarifies this problem would be greatly appreciated, aswell as any improvements I could do to my code etc.</p>
  
  <p>This is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ctime&gt;
  
  using namespace std;
  
  
  int main(int args, const char* argv[])
  {
  
  int svar = 0;
  int bokstav = 0;
  int insert;
  int build;
  int bet;
  int credit;
  int array;
  int jackpot;
  int tal;
  int spin_1x = 0;
  int spin_1y = 0;
  int spin_2x = 0;
  int spin_2y = 0;
  
  
  cout &lt;&lt; "Welcome to the one-armed bandit!" &lt;&lt; endl;
  cout &lt;&lt; endl;
  cout &lt;&lt; "To play start by betting some money!" &lt;&lt; endl;
  cout &lt;&lt; endl;
  cout &lt;&lt; "Insert 50/ 100/ 500 kr to your account!" &lt;&lt; endl;
  cout &lt;&lt; endl;
  cin &gt;&gt; insert;
  
  while (insert &lt; 50 || insert &gt; 500)
      {
          cout &lt;&lt; "You either inserted to little or to much" &lt;&lt; endl;
          cin &gt;&gt; insert;
      }
      cout &lt;&lt; "You inserted" &lt;&lt; insert;
      cout &lt;&lt; endl;
      while (insert &gt; 50)
      {
          cout &lt;&lt; "Bet some money to play!" &lt;&lt; endl;
          cout &lt;&lt; endl;
          cin &gt;&gt; bet;
          cout &lt;&lt; endl;
          while (bet !=50 &amp;&amp; bet !=100 &amp;&amp; bet !=500)
          {
              if (bet == 50) return 1;
              {
                  cout &lt;&lt; "You have betted 50 kr!" &lt;&lt; endl;
              }
              {
                  if (bet == 100) return 2;
                  {
                      cout &lt;&lt; "You have betted 100 kr!" &lt;&lt; endl;
                  }
                  {
                      if (bet == 500) 
                      {
                          cout &lt;&lt; "You have betted 500 kr!" &lt;&lt; endl;
                      }
                      char a = '£';
                      char b = '$';
                      char c = '*';
  
                      char build [4][4] = { 
                          { ' ', 'A', 'B', 'C',},
                          { '1', ' ', ' ', ' ',},
                          { '2', ' ', ' ', ' ',},
                          { '3', ' ', ' ', ' ',},
                      };
  
                      int array();
  
                      cout &lt;&lt; build[0][1] &lt;&lt; "    " &lt;&lt; build[0][2] &lt;&lt;"    "&lt;&lt; build[0][3] &lt;&lt;" " &lt;&lt; endl;
                          cout &lt;&lt; build[1][0] &lt;&lt;"|_|" &lt;&lt;"|_|" &lt;&lt; "|_|" &lt;&lt; endl
                          &lt;&lt; build[2][0] &lt;&lt;"|_|" &lt;&lt;"|_|" &lt;&lt; "|_|" &lt;&lt; endl
                          &lt;&lt; build[3][0] &lt;&lt;"|_|" &lt;&lt;"|_|" &lt;&lt; "|_|" &lt;&lt; endl;
                          return 0;
  
                      srand(time(0));
                      spin_1x=rand() % 4 + 1;
                      spin_1y=rand() % 4 + 1;
                      spin_2x=rand() % 4 + 1;
                      spin_2y=rand() % 4 + 1;
  
                      int y = 0;
                      int x = 0;
  
                      if (x == spin_1x &amp;&amp; y == spin_1y)
                      {
                          build[x][y]='0';
                          cout &lt;&lt; "Congrats you won!" &lt;&lt; endl;
                      }
                      else if (x == spin_2x &amp;&amp; y == spin_2y)
                          cout &lt;&lt; "Congrats you won!" &lt;&lt; endl;
                      cout &lt;&lt; endl;
                      cout &lt;&lt; "JACKPOT!" &lt;&lt; endl;
                      {
                          if (insert &lt;= 0)
                          {
                              cout &lt;&lt; "You dont have any money left! Game's over!" &lt;&lt; endl;
                          }
  
                          int insert;
  
                          if ((a == 7 &amp;&amp; b == 7 &amp;&amp; c == 7))
                          {
                              cout &lt;&lt; "You have won x2 your bet!($" &lt;&lt; ( bet*2) &lt;&lt; ")" &lt;&lt; endl;
                              credit = credit + (bet*2);
                          }
                          else if ((a == b == c) &amp;&amp; ! (a == 7 &amp;&amp; b == 7 &amp;&amp; c == 7))
                          {
                              cout &lt;&lt; "You have won x4 your bet!($" &lt;&lt; (bet*4) &lt;&lt; ")" &lt;&lt; endl;
                              credit = credit + (bet*4);
                          }
                          else if ((a == b || a == c || b == c) &amp;&amp; !(a == b == c) &amp;&amp; !(a == 7 &amp;&amp; b == 7 &amp;&amp; c == 7))
                          {
                              credit = credit + (bet*8);
                              cout &lt;&lt; "You have won x8 your bet!($" &lt;&lt; (bet*8) &lt;&lt; ")" &lt;&lt; endl;
                          }
                          else if ((a == b || a == c || b == c) &amp;&amp; ! (a == b == c) &amp;&amp; ! (a == 7 &amp;&amp; b == 7 &amp;&amp; c == 7))
                          {
                              credit = credit + (bet*16);
                              cout &lt;&lt; "You have won x16 your bet!($" &lt;&lt; (bet*16) &lt;&lt; ")" &lt;&lt; endl;
                          }
                          else if (( a == b || a == c || b == c) &amp;&amp; ! (a == b == c) &amp;&amp; ! (a == 7 &amp;&amp; b == 7 &amp;&amp; c == 7))
                          {
                              credit = credit + (bet*128);
                              cout &lt;&lt; "You have won x128 your bet!($" &lt;&lt; (bet*128) &lt;&lt; ")" &lt;&lt; endl;
                          }
                          else
                          {
                                  cout &lt;&lt; "You have lost your betting!($-" &lt;&lt; bet &lt;&lt; ")" &lt;&lt; endl;
                                  credit = credit - bet;
                          }
                          return credit;
                      }
                  }
                  return 0;
              }
          }
      }
  }
  </code></pre>