title: Trying to read a vector from a textfile
body: <pre><code>    while (artist &gt;&gt; forname &gt;&gt; surname &gt;&gt; bandnum)
  {
  for (int i = 0; i &lt;= bandnum; i++)
  {
  artist &gt;&gt; band[i];
  }
  for (int i = 0; i &gt; bandnum; i++)
  {
  cout &lt;&lt; band[i];
  }
  artist &gt;&gt; role;
  </code></pre>
  
  <p>The following code is how i am trying to read a vector from my text file, which is the form shown below </p>
  
  <blockquote>
    <p>john smith 3 a b c singer</p>
  </blockquote>
  
  <p>The order must be read out in first name, second name, band number, bands they played for, and then their role. <code>Artist</code> is the ifstream and <code>bandnum</code> is the amount of bands they played for, with "a b c" being their bands. The <code>band</code> is a vector as the number of bands and what bands they played for will change for each artist. When i try run this the code breaks saying "vector subscript out of range". What can i do to fix this?</p>