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:
vector<vector<int>> inputMatrix;
string line;
while(!file.eof())
{
    getline(file, line);
    stringstream ss(line);
    int num;
    vector<int> temp;
    while(ss >> num)
    {
        temp.push_back(num);        
    }
    inputMatrix.push_back(temp);
}
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.
How can I achieve this? Would it be possiple to write somewhere in this while loop or somewhere else in the code?
thank you very much in advance.
 
     
    