'C++: How to do a matrix multiplication with pointers? Error: argument of type int is incompatible with parameter of type int**

I need to multiply two matrices, I have a header file where the function product is, and I need to call it in main. I am not very familiar with pointers, so I don't understand how I should fix this.

Header file:

void product1(int **x, int **y, int **z, n);

void product1(int **x, int **y, int **z, n) {
for(int i = 0; i < n; i++) {
   for(int j = 0; j < n; j++) {
     int sum = 0;
      for(int k = 0; k < n;  k++) {
       sum += x[i][k] * y[k][j];
       }
   }
}
}
        

Main file:

for (int n = 0; n < 2000; n += step) {
    for (int i = 0; i < 2000; i++) {
        for (int j = 0; j < 2000; j++) {
            for (int k = 0; k < 2000; k++) {
                product1(i, j, k, n);

            }
        }
    }

In the row where I call the function it gives me errors for i, j, k "argument of type int is incompatible with parameter of type int**.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source