title: stoi function gives error: std::invalid_argument at memory location 0x0035E8D8. c++
body: <p>The program runs fine until it gets to the stoi function, then the program breaks and gives me this error " Microsoft C++ exception: std::invalid_argument at memory location 0x0030EE7C." I've looked at tutorials on using stoi and I'm not sure what I'm doing wrong. The flat file reads like this:</p>
  
  <pre><code>Organic
  7
  description
  light
  4
  description
  menthol
  5
  description.
  </code></pre>
  
  <p>with each word or number on a new line.  </p>
  
  <pre><code>struct ProdDescriptor
  {
      string name;
      string price;
      string descript;
  
  };
  void getProds() // reads products off of the flat file
  {
      int array = 3;
      ProdDescriptor x[3];
      ifstream ItemRead(FlatFileName); // object of the flat file
      string temp;
  
      if (ItemRead.is_open()) // opens flat file and reads
      {
          for (int i = 0; i &lt; array; i++)
          {
              ProdSpecPrice[i] = 0; // initialize 
  
              getline(ItemRead, x[i].name);
              getline(ItemRead, x[i].price);
              getline(ItemRead, x[i].descript);
  
              temp = x[i].price;
              ProdSpecPrice[i] = stoi(temp);
              ProdSpecName[i] = x[i].name;
              ProdSpecDescription[i] = x[i].descript;
          }
  </code></pre>