Hi!,
I have a text file that contains a 2 dimensional matrix, and I will have to deal with many different files with different matrix dimensions, so I decided to use vector of vectors as they double their size automatically. the problem is that I don't know how to get every line from the file in a separate row of the vector and loop on the cols, and then increment to the next row
int rows = 2; // just an initial size and I rely on doubling the size automatically
int cols = 2;
vector<vector<float> > initMatrix(rows,vector<float> (cols));
ifstream myfile("a.text");
if(!myfile.is_open())
{
//if file is not opened
cout<<"Error opening the file"<<endl;
system("pause");
}
while (myfile)
{
// I don't know how to get every line from file and loop on the cols. while the cols. size and rows size will change frequently
}
myfile.close();
thanks.