title: Input file checking using getline an >> operator in c++
body: <p>I have written a code here which reads a input file line by line and creates a vector of vectors which I then use as a matrix, later on, in my homework. This is the code:</p>
  
  <pre><code>vector&lt;vector&lt;int&gt;&gt; inputMatrix;
  string line;
  while(!file.eof())
  {
      getline(file, line);
      stringstream ss(line);
  
      int num;
      vector&lt;int&gt; temp;
  
      while(ss &gt;&gt; num)
      {
          temp.push_back(num);        
      }
      inputMatrix.push_back(temp);
  }
  </code></pre>
  
  <p>However, some input files may contain non-integer values. I would like to integrate a input check feature for the matrix creation so that when there is a non-integer value in the input file, my program would quit. </p>
  
  <p>How can I achieve this? Would it be possiple to write somewhere in this while loop or somewhere else in the code? </p>
  
  <p>thank you very much in advance. </p>