title: C++ Read txt file CSV values
body: <p>I know this post has been made before on stack overflow, and I have combined various tutorials; but why does this code cause an error on execution -  it does compile.</p>
  
  <pre><code>void leaderBoard::loadFromFile(void)
  {
      string line;
      ifstream leaderBoardFile ("leaderboard.data");
      vector&lt;string&gt; playerInfoVector;
      if (leaderBoardFile.is_open())
      {
          while ( leaderBoardFile.good() )
          {
              playerInfoVector.clear();
              getline (leaderBoardFile,line);
              std::string input = line;
              std::istringstream ss(input);
              std::string token;
              //cout &lt;&lt; line &lt;&lt; endl;
  
              while(getline(ss, token, ',')) {
                  //for current line;
                  playerInfoVector.push_back(token);
              }
  
              string firstName = playerInfoVector.at(0);
              string stringAge = playerInfoVector.at(1);
              string stringScore = playerInfoVector.at(2);
  
              //int age;
              //stringstream(stringAge) &gt;&gt;    age;
              //int score;
              //stringstream(stringScore) &gt;&gt;  score;
              //addScore(firstName,age,score);
              ////stringstream(stringAge) &gt;&gt; age;
  
              ////Add text to vector (push back)
              playerInfoVector.clear();
          }
          leaderBoardFile.close();
      }
  
      else cout &lt;&lt; "Unable to open file";
  }
  </code></pre>