title: C++ Read file into vectors
body: <p>I'm having trouble figuring out how to read a file line by line into different data type vectors. Is there a way to do this with inFile >> ? My code is below. Thanks in advance!</p>
  
  <pre><code>void fileOpen()
  {
      fstream inFile;
      inFile.open(userFile);
  
      // Check if file open successful -- if so, process
  
      if (!inFile.is_open()) {cout &lt;&lt; "File could not be opened.";}
      else
      {
          cout &lt;&lt; "File is open.\n";
  
          string firstLine;
          string line;
  
          vector&lt;char&gt; printMethod;
          vector&lt;string&gt; shirtColor;
          vector&lt;string&gt; orderID;
          vector&lt;string&gt; region;
          vector&lt;int&gt; charCount;
          vector&lt;int&gt; numMedium;
          vector&lt;int&gt; numLarge;
          vector&lt;int&gt; numXL;
  
          getline(inFile, firstLine); // get column headings out of the way
          cout &lt;&lt; firstLine &lt;&lt; endl &lt;&lt; endl;
  
          while(inFile.good()) // while we are not at the end of the file, process
          {
              while(getline(inFile, line)) // get each line of the file separately
              {
                 for (int i = 1; i &lt; 50; i++)
                 {
                    inFile &gt;&gt; date &gt;&gt; printMethod.at(i);
                    cout &lt;&lt; date &lt;&lt; printMethod.at(i) &lt;&lt; endl;
                 }
  
              }
          }
  
      }
  }
  </code></pre>