everybody, I'm newbie in C, I'm trying to build a programme to calculate the matrix, so here is my source:
#include <stdio.h>
#include <stdlib.h>
void f1(double *p, double *n, double *m, int qntF, int qntS) {
int i,j;
for(i=0; i<qntF; i++){
for (j=0; j< qntS; j++){
m[i][j] = p[i][j] + n[i][j];
}
}
for(i=0; i<qntF; i++) {
for (j=0; j< qntS; j++) {
printf("%f",m[i][j]);
}
}
}
int main() {
int i,j;
double mat1[3][5] = { {13.1, 5, 6.9, 23.87, 43},
{65, 17.75, 1.3, 9.12, 11},
{54, 3, 9.8, 23.8, 9.3} };
double mat2[3][5] = { {11, 13, 22, 34, 65},
{7, 23, 90, 4, 1},
{9.3, 13.45, 23.89, 34.65, 2.96} };
double matRes[3][5];
f1(&mat1[0][0], &mat2[0][0], &matRes[0][0], 3, 5);
}
and I get this error:
error: subscripted value is not an array, pointer, or vector
m[i][j] = p[i][j] + n[i][j];
~~~~^~
Like I got it that I'm trying to put 2 dimensions array to function but I get just one dimension array with 15 items.
Sorry, I tried to find the answer here but I could'nt.