title: Program outputs incorrect numbers from array
body: <p>Jeopardy point adding code.</p>
  <p>The program is supposed to get the number of players with a dynamic array.</p>
  <p>From there, you can enter players names and it will insert the names into a two-dimensional array.</p>
  <p>Then you can choose to call on a player to start adding points to.</p>
  <p>After looping a certain amount of times and pressing 0, the while loop will cease to run and will skip down to the for loop outputting players name and then points.</p>
  <p>Problem: If I input &quot;1&quot; for playerNumber, and I start adding points to index [0][1] and outputs numbers quite different from the original numbers I put in. If there are more than 2 players, 2 of the 3 players have random numbers while one remains an accurate point count.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  
  
  int main(void)
  {
      //GLOBAL SCOPE, all loops and other boxes can use these
      //Declaration variables w cout &amp; cin.
      int playerNumber;
      string playerNames;
      bool flag = true;
  
      cout &lt;&lt; &quot;How many players are there: &quot;;
      cin &gt;&gt; playerNumber;
      cout &lt;&lt; endl;
  
      //Array Declaration.
      string playerList[playerNumber][2]; //Dynamic array. changes during program runtime.
      int points[playerNumber]; //Dynamic array. Changes during runtime
      //GLOBAL SCOPE, all loops and other boxes can use these
  
  
      //Assigning values to arrays now.
      cout &lt;&lt; &quot;Enter the players names: &quot; &lt;&lt; endl;
  
      //Assigns player name to each row.
      for(int i = 0; i &lt; playerNumber; i++){
          cin &gt;&gt; playerNames;
          playerList[i][0] = playerNames; //Assigns players name to the array
          cout &lt;&lt; &quot;Player &quot; &lt;&lt; i + 1 &lt;&lt; &quot;: &quot; &lt;&lt; playerList[i][0] &lt;&lt; endl;
      }
  
  
      while(flag){
          //LOCAL VARIABLES
          int choice = 0; //Always reverts back to zero to prevent addition error.
          int pointsValue = 0; //Always reverts back to zero to prevent addition error.
          //LOCAL VARIALES
  
          cout &lt;&lt; &quot;Press 0 to end game, if not, enter player number: &quot; &lt;&lt; endl;
          cin &gt;&gt; choice;
  
          if(choice == 0){ //Exit out of the while loop
              flag = false;
          }
  
          else if(cin.fail()){
                  cout &lt;&lt; &quot;Not a number. Try again.&quot; &lt;&lt; endl;
                  cin.clear();
                  cin.ignore(256, '\n');
          }
  
          else if(choice &lt; 0 || choice &gt; playerNumber){
              cout &lt;&lt; &quot;Choice is less than 0 or greater than player count. Try again.&quot; &lt;&lt; endl;
          }
  
  
          else{
              cout &lt;&lt; &quot;Enter points: &quot; &lt;&lt; endl;
              cin &gt;&gt; pointsValue;
              cout &lt;&lt; endl;
              points[choice - 1] += pointsValue; //Assigns points to points array
              playerList[choice - 1][1] = (to_string(points[choice - 1])); //Assigns points to playerNumber.
          }
  
      }
  
      cout &lt;&lt; endl;
      cout &lt;&lt; &quot;END OF JEOPARDY. HERE ARE THE POINTS!!!&quot; &lt;&lt; endl;
      cout &lt;&lt; endl;
  
      //Current points for each player
      //Shows their name and points
      for(int i = 0; i &lt; playerNumber; i++){ //Loops so that player name and points are displayed
         string playerName = playerList[i][0];
         string totalPoints = playerList[i][1];
  
         cout &lt;&lt; playerName &lt;&lt; &quot; points: &quot; &lt;&lt; totalPoints &lt;&lt; endl;
  
      }
  
      return 0;
  }
  </code></pre>