I'm creating a set of functions that takes a pointer to a 2D-Array and fills the array with some data
This is how I got it right now:
17 void m4identity(float *m[4][4]) {
18 *m = (float[4][4]) { { 1, 0, 0, 0 },
19 { 0, 1, 0, 0 },
20 { 0, 0, 1, 0 },
21 { 0, 0, 0, 1 } };
22 }
But unfortunately I get a compiler error:
linalg.c:18:7: error: incompatible types when assigning to type ‘float *[4]’ from type ‘float (*)[4]’
Questions:
What is the difference between
(*)[4]and*[4]?Is there a better way to do this?
I initially tried to return a pointer to the array created inside the function but this threw another compiler error because it would be out of scope. I also want to avoid allocating space for the array from within the function as that would be hard to control.