I am having trouble reading the second matrix from my file. Can anyone help me please? Thank you!

What does the sample data in your file look like ?

Regarding your code, you need to be careful about the loop which is reading from your file. Unless your total number of records in the file is a multiple of 9 you will not read the values into the vectors correctly. Its likely you will keep looping for values even after you reach eof ..

Just how big are your matrices supposed to be? What is the input data. From your code, I see two sizes:

for (i =0; i<9; i++)
       {

	in >> num1 >> num2 >> num3;
	{
          RowA.push_back(num1);
	  RowA.push_back(num2);
	  RowA.push_back(num3);
          MatrixA.push_back(RowA);
	   RowA.clear();
	
	}
	
      }
	
		
	
    for(int i=0; i<3; i++)
   {
       for(int j=0; j<3; j++)
      {
          cout << MatrixA[i][j]; 
       }
    }

The input portion read in 9 x 3 values, for a total of 27. The output only displays a 3 x 3 matrix.

Which is it?

Since you are reading in 3x3 matrices, your loops should do just that. You have one input statement reading three values, so loop that just three times, not nine.

Thank you very much! :icon_razz:

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.