title: C++ - Failing to parse CSV into my struct
body: <p>I have a CSV with the following format:</p>
  
  <pre><code>date,fruit,quantity1,quantity2,quantity3
  2016-07-14,banana,3,20,6
  2016-07-14,banana,3,50,15
  2016-07-14,banana,0,25,15
  2016-07-14,banana,3,25,6
  2016-07-14,apple,3,10,20.5
  2016-07-14,apple,0,30,5
  2016-07-14,apple,0,5,30
  2016-07-14,peach,3,10,30.2
  2016-07-14,peach,3,40,4
  2016-07-14,peach,3,10,12
  2016-07-14,peach,0,10,8
  2016-07-14,peach,3,200,3
  </code></pre>
  
  <p>I want to parse this file and store it in a struct.  But I am getting a stack overflow error.  Where is it failing exactly?  Is it because of clashing data types in the struct?  Some of the data types are a float and I'm trying to use getline and a temporary string variable to store the info.</p>
  
  <p>Here is the complete code:</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  struct FruitInventory
  {
      string date;
      string fruit;
      float quantity1;
      float quantity2;
      float quantity3;
  };
  
  int main()
  {
      ifstream myfile;
      myfile.open("fruit_inventory.csv", ios::in);
  
      string line;
  
      FruitInventory todaysFruitSupply[15000];
  
      int i = 0;
  
      int lineCount = 0;
  
      while (myfile.good())
      {
          getline(myfile, line);
  
          stringstream mystream(line);
  
          string temp;
  
          if (i &gt; 0) //ignore header line
          {
              getline(mystream, todaysFruitSupply[i].date, ',');
              getline(mystream, todaysFruitSupply[i].fruit, ',');
              getline(mystream, temp, ',');
              todaysFruitSupply[i].quantity1 = stof(temp);
              getline(mystream, temp, ',');
              todaysFruitSupply[i].quantity2 = stof(temp);
              getline(mystream, temp, ',');
              todaysFruitSupply[i].quantity3 = stof(temp);
          }
  
          i++;
          lineCount++;
      }
  
      myfile.close();
  
      system("pause");
  
      return 0;
  }
  </code></pre>
  
  <p>EDIT: It was breaking on the last line of the file because there was a new-line character.  After deleting that, it now executes completely.  How can I make sure it can handle that correctly in the future?</p>