problems in using cin
<p>The program is to copy the first element of 'marks' vector into the 'all_marks' vector.Note that marks vector will be changed dynamically.</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
using namespace std;
istream&amp; read_info(istream&amp; in,vector&lt;double&gt;&amp; vec);
int main(int argc, const char * argv[])
{

    vector&lt;double&gt; marks;
    vector&lt;double&gt; all_marks;
    while (read_info(cin,marks))  //fails aftr last iteration due to error state of cin
       { 
          all_marks.push_back(marks[1]);
       }
    vector&lt;double&gt;::size_type indx;

    for(indx=0;indx&lt;all_marks.size();++indx)
    {
      cout&lt;&lt;all_marks[indx]&lt;&lt;endl;
    }
    return 0;
 }

 istream&amp; read_info(istream&amp; in,vector&lt;double&gt;&amp; vec)
 {
     vec.clear();
     cout&lt;&lt;"entr mrks with * after last i/p followed by EOF at the last iteration"&lt;&lt;endl;
     double x;
     while(in&gt;&gt;x &amp;&amp; x!='*')
     {
         vec.push_back(x);
     }
     return in;  //in will not be in error state until the end of last iteration
                 // which is followed by EOF
  }
</code></pre>

<p>But im not able to take the second iteration itself.Whats the problem with the code.Using 'Cin' for input seems to be very error prone.Comment if the question is not clear.</p>
