read wrong matrix error

This commit is contained in:
2024-05-20 00:02:58 +03:00
parent edda5c1750
commit 80c43efab6

19
pr5.cpp
View File

@@ -369,6 +369,25 @@ int main() {
fout.close();
}
// To test wrong matrix size input
// Saving a matrix array to a file with one matrix having different dimensions
// (uncomment this for testing)
//ofstream fout("1.txt");
//if (fout) {
// fout << "3\n";
// for (int i = 0; i < 2; i++) // Save the first two matrices normally
// fout << M[i] << "\n";
// fout << "3 3 "; // Write incorrect dimensions for the third matrix
// for (int i = 0; i < 3; i++) {
// for (int j = 0; j < 3; j++) {
// fout << (rand() % 100) << " "; // Fill the incorrect matrix with random values
// }
// }
// fout.close();
//}
// reading a matrix array from a file
Matrix<double>* M1;
ifstream fin("1.txt");