title: How to read integers till end of line?
body: <p>I'm trying to do bfs on graph,given an adjacency list.
  Here's a sample input.</p>
  
  <pre><code>1 2 3
  2 4
  1
  2 3 4
  </code></pre>
  
  <p>I know the number of lines,n (number of verices).
  Each line contains 0 to n-1 integers.</p>
  
  <p>This was an attempt but it doesnt work as it reads all the integers till the end of the input.   </p>
  
  <pre><code> for(i=0;i&lt;n;i++)
  {
     while(cin&gt;&gt;v)
     {insert(i,v);}
  }
  </code></pre>
  
  <p>I want to process each line separately.
  On searching, I found answers with vectors and stl.It would be nice if someone could come up with a more elegant solution. </p>
  
  <p>Thanks.</p>