0

Hi!

Im very new in c programming and i have a lot of problems with this easy exercise.

I have a struct for a matrix

```
typedef struct {
int dim;
float **m;
} t_matriu;
```

I have a function to create a matrix and to generate random numbers to fill it.

```
t_matriu *Crea_M ( int dim )
{
t_matriu mtr;
int i,j;
mtr.dim = dim;
mtr.m=(float **)malloc(sizeof (float*) * (dim) );
for (i = 0; i < dim; i++)
{
mtr.m[i] = (float*) malloc (sizeof (float) * (dim) );
for ( j = 0; j < dim ; j++ )
{
mtr.m[i][j] = rand() % 1000;
}
}
return mtr;
}
```

and my main is...

```
int main ( int argc, char *argv[] )
{
int num = 5;
t_matriu mtr;
t_matriu mtr2;
//Crea y rellena con aleatorios matriz A
mtr = Crea_M(num);
mtr2 = Crea_M(num);
Print_M(mtr);
Print_M(mtr2);
printf ("Fin del main!\n");
return 0;
}
```

Main, Crea_M and the definition of the struct are in different files but is not a problem with the includes, I know how to do that, Im pretty sure that the problem is in the declaration of the matrix, the arguments or the return of the function or something like that, I dont know how to use pointers.

Of course this code doesnt work...can anyone help me?? thank you so much!