0

Hi all,

I trying to add two matrices together using a typedef struct, but i seems to get an error doing this. I asked my professor, but he couldnt help me. Is there anyone who might know why this problem is caused?

Thank you so much!

Code:

```
/* Structures */
typedef struct matrix {
int rows;
int cols;
float **mat;
} Matrix;
Matrix matrix_add(Matrix a, Matrix b){
Matrix m;
int i, j;
for (i=0; i<a.rows; i++) {
for (j=0; j<a.cols; j++) {
m.mat[i][j] = (a.mat[i][j]+b.mat[i][j]);
}
}
m.rows = a.rows;
m.cols = a.cols;
return m;
}
```

*Edited 3 Years Ago by Reverend Jim*: Fixed formatting