title: How can I read the data from text file and load it into the vector?
body: <p>I want to read a data from text file using structure and load it into vector.</p>
  
  <p>so I wrote a following to do this but I failed to compile. I don't know what's wrong.</p>
  
  <p>&lt; what I did ></p>
  
  <ol>
  <li>text file contains data as follows;</li>
  </ol>
  
  <p>835,5,0,0,1,1,8.994,0</p>
  
  <p>(integer array[3], integer,integer,integer,integer,integer, float, Boolean)</p>
  
  <p>2.I declared a structure contains following data types to load data into vector;</p>
  
  <pre><code>struct unfinished
  {
      int ans[3]; // contains answer
      int max;
      int st;
      int ba;
      int outs;
      int tri;
      float elapsed;
      bool fin;
  };
  </code></pre>
  
  <p>3.I wrote a code to read a data as follows;</p>
  
  <pre><code>#define _CRT_SECURE_NO_WARNINGS
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  struct unfinished
  {
     int ans[3];
     int max;
     int st;
     int ba;
     int outs;
     int tri;
     float elapsed;
     bool fin;
  };
  
  vector&lt;unfinished&gt; read_rec(istream &amp; is)
  {
    vector&lt;unfinished&gt; rec;
    int ans[3];
    int max, st, ba, outs, tri;
    float elap;
    bool fini;
  
    while (is &gt;&gt; ans[0] &gt;&gt; ans[1] &gt;&gt; ans[2] &gt;&gt; max &gt;&gt; st &gt;&gt; ba &gt;&gt; outs &gt;&gt; tri    &gt;&gt; elap &gt;&gt; fini)
  {
      rec.emplace_back(ans[0], ans[1], ans[2], max, st, ba, outs, tri, elap, fini);
  }
  return rec;
  }
  
  int main(void)
  {
  ifstream infile("unfin_rec.txt");
  auto unfin = read_rec(infile);
  
  vector&lt;unfinished&gt;::const_iterator it;
  
  for (it = unfin.begin(); it != unfin.end(); it += 1)
  {
      cout &lt;&lt; it-&gt;ans[0] &lt;&lt; it-&gt;ans[1] &lt;&lt; it-&gt;ans[2] &lt;&lt; "," &lt;&lt; it-&gt;max &lt;&lt; "," &lt;&lt; it-&gt;st &lt;&lt; "," &lt;&lt; it-&gt;ba &lt;&lt;","&lt;&lt;it-&gt;outs&lt;&lt;","&lt;&lt;it-&gt;tri&lt;&lt;","&lt;&lt;it-&gt;elapsed&lt;&lt;","&lt;&lt;it-&gt;fin&lt;&lt; endl;
  }
  
  system("pause");
  return 0;
  }
  </code></pre>
  
  <p>I failed to compile this code. error message was: >c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0(600): error C2661: 'unfinished::unfinished' : no overloaded function takes 10 arguments</p>
  
  <p>again, I couldn't figure out what this message means. Please help!</p>
  
  <p>thanks,</p>
  
  <p>seihyung</p>