title: Out of Range Error When Reading to Struct Array
body: <p>So I'm writing a program for a database storage, the first step is to load the information from a text file to a struct array. However, I get an error message during the reading/writing process saying that the program is going into an out of range instance.</p>
  
  <pre><code>while (!inFile.eof())
  {
      getline(inFile, dataLine);              //saves the line of the file into a string
  
      a[i].name = dataLine.substr(0, 17); // 18
      a[i].author = dataLine.substr(19, 33); // 15
      a[i].vol = dataLine.substr(35, 60); // 26
      a[i].pub = dataLine.substr(62, 77); // 16
      a[i].year = dataLine.substr(79, 82); // 4
      a[i].price = dataLine.substr(84, 91); // 8
      a[i].copies = dataLine.substr(93, 96); // 3
  
  
      i++;    //moves through the array after each line.
      count++;    //counts how many lines/items there are in the file entered for the program
  }
  </code></pre>
  
  <p>I've narrowed the problem down to this section, but I can't seem to figure out what's causing it to go wrong.</p>
  
  <pre><code>terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::substr: __pos (which is 19) &gt; this-&gt;size() (which is 0)
  Aborted
  </code></pre>
  
  <p>And here is the error message I've gotten.</p>