I am attempting to read in an n × n matrix from a file and then store that matrix in a one dimensional array. I would also like to store the value for n. I have looked into various approaches but can't seem to apply them to what I'm trying to achieve.
This is what I have so far but I'm unsure what to put into the while loop.
/*READ IN THE IMAGE MATRIX FROM THE FILE*/
String lineA;
ifstream imFile;
imFile.open("imageMatrixDefined.txt");
if(imFile.fail()){
    cerr << "File cannot be found or opened" << endl;
    exit(1);
}
if(imFile.is_open(){
    cout << "file opened successfully!" << endl;
    while(!imFile.eof()){    
    }
}
The input file could look like the following:
1    2    3
2    3    1
3    3    2
where a tab separates the elements. Any suggestions would be greatly appreciated as I'm new to C++.
 
     
     
    