I want to read two matrices from two separate text files and multiply them. The matrices are 3x3 and 3x1 respectively, but I want to write the code that works for up to 10x10 matrices multiplication (so 10x10 matrix times 10x10 matrix). Below is my code, please help me! What I'm trying to do is to use for loops for rows and columns to read the files.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
int i, j;
int A[10][10], B[10][10], C[10][10];
ifstream inFile1("matrix(1).txt");
ifstream inFile2("vector(1).txt");
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
inFile1 >> A[i][j];
inFile2 >> B[i][j];
}
}
while (!inFile1.eof()) {
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
inFile1 >> A[i][j];
inFile2 >> B[i][j];
}
}
}
}