I was trying to make an array multiplication function but got some weird compilation error.
Basically the function should input two arrays where array A number of columns equal array B number of rows and output the result pointing to another array.
Here's the function:
float mul( float MatrixA, float MatrixB, int rowA, int colA, int colB, float* MatrixOut )
{
for(int a; a < rowA; a++)
{
for(int b; b < colB; b++)
{
float sum = 0;
for(int c; c < colA; c++) { sum += MatrixA[a][c] * MatrixB[c][b]; }
*MatrixOut[a][b] = sum;
}
}
}
Error message:
Matrix:37: error: invalid types 'float[int]' for array subscript
for(int c; c < colA; c++) { *MatrixOut[a][b] += MatrixA[a][c] * MatrixB[c][b]; }
^
exit status 1
invalid types 'float[int]' for array subscript