title: My program is crahing, and honestly i am confused (c++)
body: <p>For some reason my program crashes immediately after it receives the input from the user. However the weirdest part is that it crashes only if the user was to input <code>Yes</code>, not if they input <code>n</code>o. My thoughts are that it is something to do with the class <code>Players</code>. I already have tried debugging through all conventional methods. Breakpoints do not appear to work due to the fact that if I put it after the <code>cout &lt;&lt; "Is this the first time...</code>  none of the variables will have any data due to the fact that they have not been assigned. It worked flawlessly up until I made the <code>readPlayerData</code> function, then the crashing began.</p>
  
  <pre><code>using namespace std;
  
  int main() {
      mt19937 rand_engine(time(nullptr));
      vector&lt;Player&gt; plyrs;
      srand(time(NULL));
      bool firstTimer = false;
      cout &lt;&lt; "Is this the first time this program has run?" &lt;&lt; endl;
      string firstTime;
      cin &gt;&gt; firstTime;
  
      if (firstTime == "Yes" || firstTime == "yes") {
          firstTimer == true;
  
          for (int i = 0; i &lt; 30; i++) {
              int limit = 18; // rand() % (25 - 18) + 18;
              for (int w = 0; w &lt; limit; w++) {
                  int z = plyrs.size();
                  plyrs.resize(z + 1);
                  plyrs[z].setPlayeName(rand_engine);
                  plyrs[z].setPlyrVal();
                  plyrs[z].setPlayerTeam(i);
              }
          }
          string human_input;
          cout &lt;&lt; "Pick a # between 1-30, this will be your team: " &lt;&lt; endl;
          cin &gt;&gt; human_input;
          int human_teamInput = 0;
          human_teamInput = atoi(human_input.c_str());
          ofstream plyrdata;
          plyrdata.open("plyr.txt");
          plyrdata &lt;&lt; human_teamInput &lt;&lt; endl;
          plyrdata.close();
          ofstream playerSaveData;
  
          playerSaveData.open("savedata.txt");
  
          for (int i = 0; i &lt; plyrs.size(); i++) {
              playerSaveData &lt;&lt; plyrs[i].plName &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].plOvr &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].ploaw &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].pldaw &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].pldspg &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].pldsps &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].plSpg &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].plSps &lt;&lt; endl;
              playerSaveData &lt;&lt; plyrs[i].plteam
                             &lt;&lt; (i &lt; (plyrs.size() - 1) ? "\n" : "");
          }
          playerSaveData.close();
          assemble_Team_Data();
      }
  
      else {
          assemble_Team_Data();
      }
      Sleep(10000);
      return 0;
  }
  </code></pre>
  
  <p>Here is the code for the readPlayerData()</p>
  
  <pre><code>void readPlayerData() {
      numFnames = 1;
      numLnames = 1;
      string line;
      ifstream fnameFile("PlayersFname.txt");
      if (fnameFile.is_open()) {
          while (fnameFile.eof() == false) {
              plFname.resize(numFnames);
              getline(fnameFile, line);
              numFnames += 1;
          }
          fnameFile.close();
      }
      ifstream lnameFile("PlayersLname.txt");
      if (lnameFile.is_open()) {
          while (lnameFile.eof() == false) {
              plLname.resize(numLnames);
              getline(lnameFile, line);
              numLnames += 1;
          }
          lnameFile.close();
      }
  }
  void setPlayeName(mt19937&amp; rand_engine) {
      readPlayerData();
      uniform_int_distribution&lt;int&gt; fname_rand(0, numFnames);
  
      string fname = plFname[fname_rand(rand_engine)];
      uniform_int_distribution&lt;int&gt; lname_rand(0, numLnames);
  
      string lname = plLname[lname_rand(rand_engine)];
      plName = string(fname + " " + lname);
  }
  </code></pre>